jag håller på med en applikation i Flash, jag har hittat en på nätet och tänkt göra om den så den passar mej. Det är en multi uppladdare, jag får ett märkligt fel. Lägger det inte i forumet för Flash då det troligen inte är i fLASH DET GÅR FEL. Det är massor med kod. Men jag tror jag har fått fram att det har med Cookies att göra, eftersom Flash inte skickar Cookies så måste jag ha "<sessionState cookieless="UseUri" />" i Web.Config. Nu har jag använt Cookies innan på sidan och har följande inställning på RoleManager "<roleManager enabled="true" defaultProvider="roleProvider" cacheRolesInCookie="true" cookieName=".MyRolesCookie" cookieTimeout="30" cookieSlidingExpiration="true" cookieProtection="All">". Hur kan jag ändra det så det fortfarande fungerar? Har det någon betydelse att jag använder Cookies i JavaScript? Det ska det väl inte ha. Här är koden jag tror behövs Det var sessionerna som ställde till det, Jag ändrade till "<sessionState cookieless="UseUri" />" så fungerade det. Kan du inte köra med cookies, men använda cookieless bara som url till din flash-fil? Hur gör jag det? Sätter enbart den urlen till cookielass? Urlen till sidan med flashfilen menar jag.Padding is invalid
"Ett fel inträffade den: den 31 december 2008klockan: 00:31
Sida: /WebResource.axd?d=TloVPZWpAzsTYTra4NsZuA2&t=633558206781406250
Meddelande: Padding is invalid and cannot be removed.
Källa: mscorlib
MetodInt32 DecryptData(Byte[], Int32, Int32, Byte[] ByRef, Int32, System.Security.Cryptography.PaddingMode, Boolean)
Stack Trace: at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) at System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount) at System.Security.Cryptography.CryptoStream.FlushFinalBlock() at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] modifier, Int32 start, Int32 length, IVType ivType, Boolean useValidationSymAlgo) at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
"
Jag kan inte fatta detta. När jag kör applikatonen ensam i en egen mapp så fungerar det. När jag sedan lägger in den på min sida så får jag detta felSv:Padding is invalid
Sv: Padding is invalid
Web.Config
<code>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<remove verb="POST,GET" path="Upload.axd"/>
<add verb="POST,GET" path="Upload.axd" type="Upload"/>
<remove verb="POST,GET" path="Upload2.axd"/>
<add verb="POST,GET" path="Upload2.axd" type="Upload2"/>
</httpHandlers>
</code>
.default.aspx
<code>
<body>
<form id="form1" runat="server">
<div>
<%--
The flash upload control. Source is located in the FlashUplod project with this solution.
The control encapsulates the creation of the flash object and embeds the .swf file
within the FlashUpload.dll.
Parameters:
UploadPage: the page to upload to. This can be a HttpHandler, an .aspx page, an .asp page;
any page that can accept uploaded files. This sample project uses a HttpHandler
which in my opinion is the best option.
OnUploadComplete: A javascript function which is called after all the files are uploaded.
--%>
<FlashUpload:FlashUpload ID="flashUpload" runat="server"
UploadPage="Upload.axd" OnUploadComplete="UploadComplete()"
FileTypeDescription="Images" FileTypes="*.gif; *.png; *.jpg; *.jpeg"
UploadFileSizeLimit="10485760" TotalUploadSizeLimit="41943040" />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click"></asp:LinkButton>
</div>
</form>
</body>
</code>
.default.aspx.cs (Sidan jag laddar upp från)
<code>
protected void Page_Load(object sender, EventArgs e)
{
// example of forms based authentication
// check if user is authenticated because all files in folder are marked to allow
// anonymous access (see web.config in UploadPage folder). This is because of
// the flash bug that does not send cookies set in non IE browswers
if (!User.Identity.IsAuthenticated)
{
FormsAuthentication.RedirectToLoginPage();
return;
}
// allows the javascript function to do a postback and call the onClick method
// associated with the linkButton LinkButton1.
string jscript = "function UploadComplete(){" + ClientScript.GetPostBackEventReference(LinkButton1, "") + "};";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "FileCompleteUpload", jscript, true);
// Adds query string info to the upload page
// you can also do something like:
// we UrlEncode it because of how LoadVars works with flash,
// we want a string to show up like this 'CategoryID=3&UserID=4' in
// the uploadPage variable in flash. If we passed this string without
// UrlEncode then flash would take UserID as a seperate LoadVar variable
// instead of passing it into the uploadPage variable.
// then in the httpHandler we get the CategoryID and UserID values from
// the query string. See Upload.cs in App_Code
//flashUpload.QueryParameters = "categoryId=14"; // Server.UrlEncode(Request.QueryString.ToString());
// example use of cookieless sessions (flash does not send cookies set in non IE browswers
Session["temp"] = "hi";
// sends the identity of the user to the upload page using query string parameters. Used with forms authtication.
FormsIdentity cIdentity = User.Identity as FormsIdentity;
string encryptString = FormsAuthentication.Encrypt(cIdentity.Ticket);
flashUpload.QueryParameters = string.Format("User={0}", encryptString);
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
// Do something that needs to be done such as refresh a gridView
// say you had a gridView control called gvMyGrid displaying all
// the files uploaded. Refresh the data by doing a databind here.
// gvMyGrid.DataBind();
}
</code>
.Upload.cs
<code>
public class Upload : IHttpHandler, IRequiresSessionState
{
public Upload()
{
}
#region IHttpHandler Members
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
// Example of using a passed in value in the query string to set a categoryId
// Now you can do anything you need to witht the file.
//int categoryId = 0;
//if (!string.IsNullOrEmpty(context.Request.QueryString["CategoryID"]))
//{
// int.TryParse(context.Request.QueryString["CategoryID"],out categoryId);
//}
//if (categoryId > 0)
//{
//}
string temp = context.Session["temp"].ToString();
string EncryptString = context.Request.QueryString["User"];
FormsAuthenticationTicket UserTicket = FormsAuthentication.Decrypt(EncryptString);
if (!UserTicket.Expired && context.Request.Files.Count > 0 )
{
// get the applications path
string uploadPath = context.Server.MapPath(context.Request.ApplicationPath + "/Upload");
// loop through all the uploaded files
for(int j = 0; j < context.Request.Files.Count; j++)
{
// get the current file
HttpPostedFile uploadFile = context.Request.Files[j];
// if there was a file uploded
if (uploadFile.ContentLength > 0)
{
// save the file to the upload directory
//use this if testing from a classic style upload, ie.
// <form action="Upload.axd" method="post" enctype="multipart/form-data">
// <input type="file" name="fileUpload" />
// <input type="submit" value="Upload" />
//</form>
// this is because flash sends just the filename, where the above
//will send the file path, ie. c:\My Pictures\test1.jpg
//you can use Test.thm to test this page.
//string filename = uploadFile.FileName.Substring(uploadFile.FileName.LastIndexOf("\\"));
//uploadFile.SaveAs(string.Format("{0}{1}{2}", tempFile, "Upload\\", filename));
// use this if using flash to upload
uploadFile.SaveAs(Path.Combine(uploadPath, uploadFile.FileName));
// HttpPostedFile has an InputStream also. You can pass this to
// a function, or business logic. You can save it a database:
//byte[] fileData = new byte[uploadFile.ContentLength];
//uploadFile.InputStream.Write(fileData, 0, fileData.Length);
// save byte array into database.
// something I do is extract files from a zip file by passing
// the inputStream to a function that uses SharpZipLib found here:
// http://www.icsharpcode.net/OpenSource/SharpZipLib/
// and then save the files to disk.
}
}
}
// Used as a fix for a bug in mac flash player that makes the
// onComplete event not fire
HttpContext.Current.Response.Write(" ");
}
#endregion
}
</code>Sv: Padding is invalid
Nu har jag en följdfråga, nu visas ju sessionsid(tror jag det är) i frågesträngen, kan man på nåt sätt gömma den så den inte syns? Det är ju kassa när man lägger till sidan till favoriter, då kommer ju sessionsid med och man får fel när man klickar på länken. Nu ser adressen ut så här i adressfältet.
"http://www.DOMÄN.COM/mh2/(S(zdjh4z55cegug445cccao4jx))/Default.aspx"Sv:Padding is invalid
Sv: Padding is invalid