2016-02-09 237 views
1

我收到了我的应用程序这个错误,当我尝试模拟有人用我的形式篡改宽处理异常部位...我怎样才能在vb.net

Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. 

我明白为什么会发生什么它可以保护我,并且我希望它保持原位。 我想要做的是更好地处理它。显示一条更好的信息,说您的输入或类似信息有问题,而不是这个.net崩溃。

有没有办法我能赶上这个异常,并处理它在我的web.config文件中以类似的方式状态错误?

e.g

<customErrors mode="Off" defaultRedirect="Errors/GenericErrorPage.aspx"> 
     <error statusCode="403" redirect="Errors/NoAccess.htm" /> 
     <error statusCode="404" redirect="Errors/FileNotFound.htm" /> 
    </customErrors> 
+1

恕我直言,你应该处理它尽可能靠近源地,但总是有选项[处理未捕获的异常(http://www.asp.net/web-api/overview/error-handling/web- API-全局错误处理) - 只是谷歌它 - 有相当多的地方,你可以连接多达那些 – Carsten

+0

感谢您的评论和链接。我们有很多的旧形式上有没有真正有足够的异常处理长期运行webfroms项目......这将是很好处理集体对于此问题! – dstewart101

+1

给予攻击者详细的错误信息是非常接近的事情不要做列表的顶部。 –

回答

0

好了,我做了一些错误记录。发现这个异常产生了500错误。我可以在webconfig中处理这个通用的重定向,以满足我的需求。

像这样:

<customErrors mode="On" defaultRedirect="Errors/GenericErrorPage.aspx"> 
    <error statusCode="500" redirect="Errors/IllegalErrorPage.aspx" /> 
</customErrors> 

感谢那些谁了评论的时间。