CodeNoob
CodeNoob

Reputation: 411

Error executing child request for

In my MVC3 application I'm getting the above mention error when I try to handle a maximum request exceeded error.

I'm handling the exception at the application level. I'm trying to redirect to an error page that's located in the Shared folder of the views.

I'm using the code below to redirect to an error page if the request size is over the limit.

 this.Server.ClearError();
 this.Server.Transfer("~/Views/Shared/NotAuthorised.cshtml");

This is the error im getting.

Error executing child request for /SiteName/Views/Shared/NotAuthorised.cshtml

Upvotes: 3

Views: 5648

Answers (1)

Wouter de Kort
Wouter de Kort

Reputation: 39898

According to the Microsoft documentation (Error Executing Child Request" Error Message When You Use Server.Transfer or Server.Execute in ASP.NET Page) you cannot use Server.Transfer after an application level error.

Microsoft Internet Information Services (IIS) dispatches the Server.Transfer or the Server.Execute request to the appropriate Internet Server Application Programming Interface (ISAPI) extension based on the extension of the requesting file. For example, a request for an .aspx page is dispatched to the Aspnet_isapi.dll ISAPI extension.

After the request is dispatched to appropriate ISAPI extension, the ISAPI extension cannot call another ISAPI extension. You receive the error message that is listed in the "Symptoms" section because the Aspnet_isapi.dll file, which handles requests to ASP.NET pages, cannot forward the request to the Asp.dll file, which handles requests to ASP pages.

You can however use Response.Redirect(path) like this:

Response.Redirect("Home/About");

Upvotes: 4

Related Questions