ASP.NET Base-64 字符串中的无效字符
我最近在我的网站上实现了 ELMAH,我注意到我们经常收到“Base-64 字符串中的无效字符”错误。我自己从未触发过它,我们的用户也没有抱怨过它,所以我不知道发生了什么。从我所能找到的一点来看,视图状态似乎可能变得太大或被损坏或其他什么。有谁知道造成这种情况的原因以及如何预防?以下是我认为 YSOD 中的相关内容。
[FormatException: Invalid character in a Base-64 string.]
[ViewStateException: Invalid viewstate.
[HttpException (0x80004005): The client disconnected.]
我可以对这些错误做些什么,还是应该在 ELMAH 中过滤它们?
I recently implemented ELMAH on my site and I have noticed that we frequently get the "Invalid character in a Base-64 string" error. I have never triggered it myself and none of our users have complained about it so I don't know what is going on. From the little I was able to find about it it seems like the viewstate might be getting too big or becoming corrupted or something. Does anybody know what causes this and how to prevent it? Here are what I believe are the pertinent lines in the YSOD.
[FormatException: Invalid character in a Base-64 string.]
[ViewStateException: Invalid viewstate.
[HttpException (0x80004005): The client disconnected.]
Is there anything I can do about these errors or should I just filter them in ELMAH?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我的经验,此错误往往是由用户双击触发回发的按钮引起的。第二个回发请求取消第一个回发请求。第一个请求的viewstate只是部分提交,所以无效,但是错误无法发送到浏览器,因为已经断开连接,从而触发了顶级错误。如果用户做某事两次导致麻烦,这可能是一个更大的问题。否则,这些错误可以简单地被过滤掉。下面是过滤 ELMAH 中类似错误的一个很好的示例:
https://stackoverflow.com/a/2549509/267448
如果您使用的是 ASP.NET WebForms,这里有一些代码在回发期间禁用触发控制:
http://disturbedbuddha.wordpress .com/2007/12/10/disabling-a-trigger-control-during-asynchronous-postback/
请注意,如果禁用 HTML 按钮,它被排除在表单变量之外,因此服务器端 Click 事件不会触发。将其更改为 解决这个问题。在 WebForms 中,这将是。
上面的内容适用于 WebForms AJAX 页面,但这里还有一些我为其他页面想出的 jQuery。
In my experience, this error tends to be cause by the user double-clicking on a button that triggers a postback. The second postback request cancels the first. The viewstate of the first request is only partially submitted, so it is invalid, but the error can't be sent to the browser because it has disconnected, which triggers the top-level error. This may be a bigger problem if the user doing something twice causes trouble. Otherwise, these errors can simply be filtered. Here's a good example of filtering out similar errors in ELMAH:
https://stackoverflow.com/a/2549509/267448
If you're using ASP.NET WebForms, here's some code to disable the triggering control during postback:
http://disturbedbuddha.wordpress.com/2007/12/10/disabling-a-trigger-control-during-asynchronous-postback/
Beware that if you disable an HTML <input type="submit"> button, it is excluded from your form variables, so your server-side Click event doesn't fire. Changing it to an <input type="button"> fixes that. In WebForms, that would be <asp:Button UseSubmitBehavior="False" />.
The above works with WebForms AJAX pages, but here's also a little bit of jQuery I came up with for other pages.
这可能就是事物的配置方式。看一下:
http://groups.google.com/group/elmah/browse_thread/thread/ec9c4bdddaa1a9e/9108b48d3def87db?lnk=gst&q=viewstate+elmah#9108b48d3def87db
更新
尝试并确定它发生的地方。可能有几个潜在的原因:
"无效字符使用 ASP.NET 和 C# 在 Base-64 字符串中
asp.net Base-64 字符串中的无效字符
归根结底,如果正如您所说,它不会在生产中造成任何问题,那么您可以过滤掉这些错误。尝试将 EnableViewStateMac 设置为 false?
It might be how things are configured. Take a look at this:
http://groups.google.com/group/elmah/browse_thread/thread/ec9c4bdddaa1a9e/9108b48d3def87db?lnk=gst&q=viewstate+elmah#9108b48d3def87db
UPDATE
Try and identify where it is occurring. There may be several potential causes:
"Invalid Character in Base-64 String" using ASP.NET and C#
asp.net Invalid character in a Base-64 string
At the end of the day, if as you say, it is not causing any problem in production, then you can filter out these errors. Try setting EnableViewStateMac to false?