Usuário com melhor resposta
Erro em aplicação Asp.net MVC

Pergunta
-
Pessoal,
boa tarde... estou desenvolvendo uma aplicação usando o framework 3.5 e mvc, deu um erro que não consigo resolver nem a pau..... ele é esse...
Se alguem ai já passou por isso é puder me ajudar fica agraçdecido
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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: 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.
Source Error:
Line 20: <div id="logindisplay">
Line 21:
Line 22: <% Html.RenderPartial("LoginUserControl"); %>
Line 23:
Line 24: </div>
Source File: d:\Projects\Syscap\Source\AdminWeb\AdminWeb\AdminWeb\Views\Shared\Site.Master Line: 22
Stack Trace:
[HttpException (0x80004005): Unable to validate data.]
System.Web.Configuration.MachineKeySection.GetDecodedData(Byte[] buf, Byte[] modifier, Int32 start, Int32 length, Int32& dataLength) +2657984
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +203
[ViewStateException: Invalid viewstate.
Client IP: 127.0.0.1
Port:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
ViewState: /wEPDwUJOTI0NjcyNTU5ZGQ=
Referer: http://localhost:1772/User/NewUser
Path: /User/NewUser]
[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) +267
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +282
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +198
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +83
System.Web.UI.Page.LoadAllState() +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext) +87
System.Web.Mvc.ViewUserControl.RenderView(ViewContext viewContext) +150
System.Web.Mvc.WebFormView.RenderViewUserControl(ViewContext context, ViewUserControl control) +60
System.Web.Mvc.WebFormView.Render(ViewContext viewContext, TextWriter writer) +139
System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, IViewEngine engine) +315
System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName) +42
ASP.views_shared_site_master.__Renderform1(HtmlTextWriter __w, Control parameterContainer) in d:\Projects\Syscap\Source\AdminWeb\AdminWeb\AdminWeb\Views\Shared\Site.Master:22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +98
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +59
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +68
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +37
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
System.Web.UI.Page.Render(HtmlTextWriter writer) +26
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +42
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.views_user_newuser_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\a7b83c1f\5ad55eca\App_Web_rgyosiqe.0.cs:0
System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext) +87
System.Web.Mvc.WebFormView.RenderViewPage(ViewContext context, ViewPage page) +74
System.Web.Mvc.WebFormView.Render(ViewContext viewContext, TextWriter writer) +105
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +542
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ActionResult actionResult) +16
System.Web.Mvc.<>c__DisplayClass13.<InvokeActionResultWithFilters>b__10() +17
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +369
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionResultWithFilters>b__12() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ActionResult actionResult, IList`1 filters) +372
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +389
System.Web.Mvc.Controller.ExecuteCore() +177
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +20
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +4
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +123
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +36
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +4
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64- Movido C. Augusto Proiete [MVP]Moderator sexta-feira, 2 de outubro de 2009 00:18 Movendo para fórum apropriado (De:ASP .NET)
Respostas
-
Olá Henry,
Acho muito esquisito esse erro acontecer, justamente porque não há ViewState no ASP .NET MVC
.
Por acaso você está utilizando algum server control do ASP .NET?
Pode mostrar como está o ASPX da página que provoca esse erro?
De qualquer forma, veja se o artigo abaixo ajuda:
http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
Abraços,
Caio Proiete -
Henry,
só complementando a resposta do Caio, parece que você está misturando WebForms com o MVC Framework... Verifique isso...
Ricardo Oneda
http://oneda.mvps.org/blog
Todas as Respostas
-
Olá Henry,
Acho muito esquisito esse erro acontecer, justamente porque não há ViewState no ASP .NET MVC
.
Por acaso você está utilizando algum server control do ASP .NET?
Pode mostrar como está o ASPX da página que provoca esse erro?
De qualquer forma, veja se o artigo abaixo ajuda:
http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
Abraços,
Caio Proiete -
Henry,
só complementando a resposta do Caio, parece que você está misturando WebForms com o MVC Framework... Verifique isso...
Ricardo Oneda
http://oneda.mvps.org/blog -
-
Ricardo, resolvi o meu problema tirando o runat="server" do meu form e colocando no lugar o using (Html.BeginForm()) {}
Muito obrigado.
[]´s
Diego Koga- Sugerido como Resposta Koga, Diego quarta-feira, 10 de fevereiro de 2010 18:19