I have problem with Uploadify:
I log in the project using:
FormsAuthentication.SetAuthCookie("myName", false);
Then, I want to upload some files using:
@{
tring auth = @Request.Cookies[FormsAuthentication.FormsCookieName]
== null ?
string.Empty
:
Request.Cookies[FormsAuthentication.FormsCookieName].Value;
}
$("#fileuploader").uploadify({
uploader: '@Url.Content("~/Scripts/uploadify.swf")',
script: '@Url.Action("ABF", "Upload")',
scriptData: { token: "@auth" },
fileDataName: 'file',
buttonText: 'Upload file',
multi: false,
sizeLimit: 22222222222,
simUploadLimit: 1,
cancelImg: '@Url.Content("~/Images/uploadify-cancel.png")',
auto: true,
onError: function(event, queueID, fileObj, errorObj) {
$('#file-type-id-list').attr('disabled','');
alert("Error ! Type: [" + errorObj.type + "] Info [" + errorObj.info + "]");
}
});
my controller's action:
[HttpPost]
public ActionResult ABF(HttpPostedFileBase file)
{
bool isLogged = User.Identity.IsAuthenticated;
}
what's curious, if I step in that action by uploadify's post method, the isLogged
is false
. If I change that action to [HttpGet]
and step inside it by a normal request, isLogged
is true
. Why ?
Ok, I've fixed it. I had to add one field within the scriptData
and modify the Global.asax
file a bit. Here's the complete answer