2010-08-04 53 views
0

我使用asp.net + MVC1.0並在一個網頁中我有幾種形式,每種形式內我已經調用了以下函數AntiForgeryToken()來生成一個隱藏值,並在控制器功能我有一個驗證屬性。Base-64字符數組的長度無效

當我使用JMeter的,並使用正則表達式,然後上傳我的表單服務器令牌捕獲令牌,我發現它拋出這樣的例外:


Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.FormatException: Invalid length for a Base-64 char array. 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082 

[FormatException]: Invalid length for a Base-64 char array. 
    at System.Convert.FromBase64String(String s) 
    at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) 
    at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) 
    at System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String serializedToken) 
[HttpAntiForgeryException]: A required anti-forgery token was not supplied or was invalid. 
    at System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String serializedToken) 
    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) 
    at System.Web.Mvc.Controller.ExecuteCore() 
    at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) 
    at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) 
    at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) 
    at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) 
    at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) 
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments. 

而且我相信捕獲的令牌是正好和我們生成的一樣,爲什麼會發生這種異常?

+0

你真的能打印出有問題的base-64字符串嗎?它很容易檢查是否正確。 – Akusete 2010-08-04 07:49:43

回答

1

剛剛解決,因爲我沒有編碼令牌之前發佈到服務器。

相關問題