![](/img/trans.png)
[英]ASP.NET 4.5 throws 502.5 as a virtual application in Azure Web App under a ASP.NET Core 2.0 application
[英]Error while posting data from ASP.Net 4.5 to ASP.Net 2.0 web application
我們遇到了以下情況:
當他們將數據從其頁面之一發布到我們的頁面時,我們會遇到系統錯誤。 為了驗證該問題,我已在同一服務器上部署了兩個Web應用程序,並嘗試將表單從webapp 1(在4.5上)發布到webapp 2(在2.0上)。 我正在錯誤以下。
[ViewStateException: Invalid viewstate.
Client IP: 127.0.0.1
Port: 63153
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
ViewState: /wEPDwUKLTM1MTA1NjA1MmRk6CPd6yG4r8HEbqBZi3i4jiLLnZotIlX7+6zAZaceaGY=
Referer: http://localhost/test4/default.aspx
Path: /test2/default.aspx]
[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +148
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +11065601
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +59
System.Web.UI.HiddenFieldPageStatePersister.Load() +11065704
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +11150648
System.Web.UI.Page.LoadAllState() +46
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11146167
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +11145706
System.Web.UI.Page.ProcessRequest() +91
System.Web.UI.Page.ProcessRequest(HttpContext context) +240
ASP.default_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\test2\b4717a74\d7ba8639\App_Web_ha1suqrp.0.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
我嘗試了以下方法:
Page標記中的EnableViewState = false。 但是.Net仍在添加_VIEWSTATE隱藏變量。
添加了Javascript函數,以將_VIEWSTATE隱藏變量設置為空。 這解決了問題。
盡管第二工作解決方案解決了該問題,但是我正在尋找更好的方法來解決此類問題。
EnableViewState = false
僅關閉ViewState,而不關閉ASP.NET服務器控件的控件狀態,這就是為什么您仍然具有隱藏的VIEWSTATE控件的原因。
ViewState在服務器上進行了哈希編碼,因此您應使用相同的密鑰來生成哈希。 您在兩個應用程序/服務器<machinekey>
machine.config文件中的<machinekey>
設置為相同的值。 默認值為AutoGenerate
,這意味着每個服務器都有自己的機器密鑰。 您可以在這里找到更多信息
另外,您可以通過將EnableViewstateMac
設置為false(基本上是您的錯誤消息所說的內容)來關閉哈希處理。 這樣,用戶可以操縱您的ViewState。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.