I’m writing an ASP.NET MVC3 web application and user authentication fails (user is not authenticated) when I’m calling an action method with Ajax. My call looks like this:
$(function () {
$("#picture").makeAsyncUploader({
upload_url: '@Url.Action("AsyncUpload", "Profile")',
flash_url: '/Scripts/swfupload.swf',
button_image_url: '/Scripts/blankButton.png'
});
});
where makeAsyncUploader is a function in a separate js file that handles all AJAX stuff. I’ve tried debugging the application, and it looks like no cookies are being sent to me with the request. Does anyone know what’s the problem?
I know it’s quite old question but I had exactly the same problem today so I will answer it.
There is a bug in the Flash plg for Firefox. It doesn’t send cookie when uploading files.
My solution:
1) Create new authorize attribute
2) Controller
3) Modify your js (formData, scriptData didn’t work for me so I added a query string)
I hope it will help someone