.Net 4 및 IIS6 (Win2003 서버)에서 MVC3 웹 응용 프로그램을 실행 중입니다. 간헐적으로 우리는 오류 메시지 다음 캡처 할 수 있습니다 : 뷰에서MVC3 AntiForgeryToken 관련 문제, 깊이있는 프레임 워크
System.ArgumentException: Value cannot be null or an empty string.
Parameter name: serializedToken
at System.Web.Helpers.AntiForgeryDataSerializer.Deserialize(String serializedToken)
at System.Web.Helpers.AntiForgeryWorker.GetAntiForgeryTokenAndSetCookie(HttpContextBase httpContext, String salt, String domain, String path)
at System.Web.Helpers.AntiForgeryWorker.GetHtml(HttpContextBase httpContext, String salt, String domain, String path)
at System.Web.Helpers.AntiForgery.GetHtml(HttpContextBase httpContext, String salt, String domain, String path)
at System.Web.Mvc.HtmlHelper.AntiForgeryToken(String salt, String domain, String path)
at System.Web.Mvc.HtmlHelper.AntiForgeryToken()
at ASP._Page_Views_Introduction_GetStarted_cshtml.Execute() in d:\MyProject\Views\ControllerName\ViewName.cshtml:line 43
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.StartPage.RunPage()
at System.Web.WebPages.StartPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
을 우리가 코드
using (Html.BeginForm("ActionName", "ControllerName"))
{
@Html.AntiForgeryToken()
... other codes ...
}
이 내가 코딩를 잘해야한다고 생각
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ActionName()
{
// other logic here
return RedirectToAction("Something", "Something");
}
같은 수신 액션 메소드가 보인다. 누구도 비슷한 경험을 한 사람 있습니까?
내 코드에서 나는 어떤 쿠키 데이터도 건드리지 않는다. – hardywang
하지만 파이어 버그를 사용하여 어떤 쿠키가 전송되었는지 확인 했습니까? __ RequestVerificationTokenxxxx__ 쿠키는 어떻게 생겼습니까? 쿠키는 기본적으로 경로를 지정하지 않으므로 도메인의 다른 응용 프로그램간에 공유되므로 동일한 도메인의 다른 응용 프로그램에서 변경되었을 수 있습니다. – Jacob