1

We currently have a MVC 2 application that has been running on .NET 4.0. As of this last week we performed all windows updates and .NET framework updates.

We are no longer able to run our web application and receive an error of: System.PlatformNotSupportedException - This operation requires IIS integrated pipeline mode

We have traced the issue down to using HTML.AntiForgery() tokens. If we comment these out we are able to run the application properly.

Is anyone aware of a reason why this method cannot be used anymore or why it is throwing an error?

Here is the Stack Trace:

Error:
System.PlatformNotSupportedException  - This operation requires IIS integrated pipeline mode.

Stacktrace:
System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. ---> System.TypeInitializationException: The type initializer for 'FormatterGenerator' threw an exception. ---> System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.PlatformNotSupportedException: This operation requires IIS integrated pipeline mode.
   at System.Web.HttpRequest.InsertEntityBody()
   at System.Web.TraceContext.InitRequest()
   at System.Web.TraceContext.VerifyStart()
   at System.Web.TraceContext.Write(String category, String message, Exception errorInfo, Boolean isWarning, Boolean writeToDiagnostics)
   at System.Web.TraceContext.Write(String category, String message)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   --- End of inner exception stack trace ---
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.Mvc.AntiForgeryDataSerializer.FormatterGenerator.TokenPersister.CreateFormatterGenerator()
   at System.Web.Mvc.AntiForgeryDataSerializer.FormatterGenerator..cctor()
   --- End of inner exception stack trace ---
   at System.Web.Mvc.AntiForgeryDataSerializer.Deserialize(String serializedToken)
   at System.Web.Mvc.HtmlHelper.GetAntiForgeryTokenAndSetCookie(String salt, String domain, String path)
   at System.Web.Mvc.HtmlHelper.AntiForgeryToken(String salt, String domain, String path)
   at ASP.views_account_login_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at System.Web.Mvc.ViewPage.ProcessRequest(HttpContext context)
   at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
   at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage)
   at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm)
   at System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass14.<InvokeActionResultWithFilters>b__11()
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
   at System.Web.Mvc.Controller.ExecuteCore()
   at System.Web.Mvc.MvcHandler.<>c__DisplayClass8.<BeginProcessRequest>b__4()
   at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
brsmith
  • 11
  • 2

3 Answers3

4

Looks like a bug in MVC 2. Can you disable tracing and try running the application again? To disable tracing, put this in Web.config (see MSDN):

<system.web>
  <trace enabled="false" />
</system.web>

Alternatively, you can try upgrading the application to MVC 3 or later, which uses a different anti-forgery mechanism under the covers and shouldn't conflict with ASP.NET's tracing mechanism.

Levi
  • 32,628
  • 3
  • 87
  • 88
  • 1
    +1 Not sure this is directly a bug in MVC2, but I can confirm that disabling tracing solves my issue, and I was also running in integrated mode. So this answer is correct in solving the issue as far as I can tell, but doesn't explain the root cause. I say it's not necessarily a bug in MVC because I was calling Server.Execute from a WebForms page to render another aspx "page" within it and I got the same error and same last part of the stack trace, but only when POSTing. GET requests worked fine. Disabling tracing solved the issue, but I would still like to know why it happens. – Paul Aug 22 '14 at 14:10
1

This means your IIS instance is running in classic pipeline mode, not integrated pipeline mode. You change it by setting it in the Application Pool's settings within IIS.

http://yanziyang.files.wordpress.com/2010/11/screenshot00172.jpg

Haney
  • 32,775
  • 8
  • 59
  • 68
  • David, thank you, but we are running it in integrated pipeline mode. We are able to make the app run when we comment out the antiforgery token. – brsmith Mar 08 '14 at 00:09
  • @brsmith that's odd. Maybe paste your web.config? I wonder if something is weird in the `system.webServer` namespace there. – Haney Mar 08 '14 at 03:12
0

I am not aware of any breaking changes to the AntiForgery ticket but have you tried changing the IIS App Pool configuration to Integrated Pipeline? Check out this SO posting to understand the differences.

What is the difference between 'classic' and 'integrated' pipeline mode in IIS7?

Community
  • 1
  • 1
Matthew Verstraete
  • 6,335
  • 22
  • 67
  • 123