Вопрос

When running one of my Visual Studio web performance tests, I noticed intermittent exceptions when trying to decode viewstate:

Message: Invalid length for a Base-64 char array.

Call Stack: 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.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) at System.Web.UI.HiddenFieldPageStatePersister.Load()

This only happens on one test at a single spot. Doing some research I noticed that the viewstate sent by the client and the viewstate received by the server differed only in that all plus (+) characters became spaces ( ).

What is causing this?

Это было полезно?

Решение

ASP.NET expects that the _VIEWSTATE hidden form field is URL-encoded before it reaches the server. When ASP.NET receives a request, it URL-decodes the _VIEWSTATE parameter, which is known to turn pluses into spaces.

Setting the URL Encode property to true on the _VIEWSTATE hidden form field in the webtest caused the bug to go away.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top