0
我試圖在ASP.NET MVC 2 Web應用程序中執行上載文件,但出現錯誤。 未提供所需的防僞標記或無效。FileUplaod:未提供所需的防僞標記或無效
有我的aspx代碼:
<% using (Html.BeginForm("ImportFile", "Suivi", FormMethod.Post, new { enctype = "multipart/form-data" }))
{ %>
<input type="file" id="fileUpload" name="fileUpload" />
<input type="submit" value="Import" />
<% } %>
而且有我的方法在我的控制器:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ImportFile(HttpPostedFileBase fileUpload)
{
if(fileUpload == null)
{
//Process files
}
return View();
}
而且有錯誤堆棧:
A required anti-forgery token was not supplied or was invalid.
at System.Web.Mvc.ValidateAntiForgeryTokenAttribute.OnAuthorization(AuthorizationContext filterContext)
at System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
那麼,是我的問題 ?
乾杯
Skilpit