【发布时间】:2014-09-09 21:13:19
【问题描述】:
我知道这已在这里发布了很多次,并提出了宝贵的建议和修复建议。但他们都没有帮助。 我们有一个电子商务网站,它是在线订购系统。我们的网站托管在带有 .net framework 4.0 的 IIS 7.0 上。(这是唯一在 IIS 上运行的网站)。在我们的测试环境中,一切正常,我们部署了它。 现在,当用户尝试访问该站点或者如果他在该站点中并浏览到其他页面时,我们会收到 MAC ERROR,则用户将面临此错误。这是堆栈跟踪。 例外:视图状态 MAC 的验证失败。如果此应用程序由 Web Farm 或集群托管,请确保配置指定相同的 validationKey 和验证算法。 AutoGenerate 不能在集群中使用。
Stack Trace: System.Web.HttpException
Stack Trace:
at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) at System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString, Purpose purpose) at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Deserialize(String serializedState, Purpose purpose) at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter2 formatter, String serializedState, Purpose purpose) at System.Web.UI.HiddenFieldPageStatePersister.Load() at System.Web.UI.Page.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.pages_usagereports_index_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
当我们在基本页面中实施代码以修复 CSRF 问题时,我们开始遇到此问题。 如果我们取出代码并与用户一起测试,我们不会收到任何错误。 到目前为止,我们已经尝试了这些解决方案 1) 应用机器密钥到网站,即使我们不是网络农场环境。 2) 我们不想将 enableviewstate 禁用为 false 或将 viewstateencryption 模式禁用为 never,因为最好不要这样做。我们甚至尝试过,但没有帮助。 3)我们尝试为 base.viewstateuserkey 分配不同的组合,例如 userhostaddress 和 user Agent 的组合,但它没有帮助。 4) 我们从此链接使用了 Microsoft .net 网络保护库 http://software-security.sans.org/developer-how-to/developer-guide-csrf 在此之后,我们开始收到另一个错误
Inner Exception Type: System.InvalidOperationException
Inner Exception: Validation of Anti-XSRF token failed.
Inner Stack Trace:
at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.signin_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
现在我们遇到了两个错误。 MAC 错误和 Anti XSRF 错误。 搜索了这个错误,我看到了很多帖子,但我试过了。他们都没有帮助。 非常感谢您对此提出任何建议。
提前致谢
【问题讨论】:
标签: asp.net