20

I am currently deploying my application built using RC of MVC ASP.NET on the production server which is showing nothing now. The routes in my global.ascx are typical i.e.

routes.MapRoute(
            "Default",                                              // Route name
            "{controller}.aspx/{action}/{id}",                           // URL with parameters
            new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
        );
        routes.MapRoute(
          "Root",
          "",
          new { controller = "Home", action = "Index", id = "" }
        );

Can any one figure out why it is showing me only blank pages

Sorry i forget to mention the it is IIS 6

Interestingnly it is also working on my local IIS (i.e. both local built in with VS & standard with XP) as well

harriyott
  • 10,505
  • 10
  • 64
  • 103
Gripsoft
  • 2,570
  • 7
  • 27
  • 30

13 Answers13

23

You will also get a blank page when you have error handling setup in your global.asax and something generic is wrong (like an assembly that could not be found).

When you disable it in the global.asax, you can see the server error. Don't forget to enable it again after fixing those initial bugs.

protected void Application_Error(object sender, EventArgs e)
{
    Exception exception = Server.GetLastError();
    RouteData routeData = new RouteData();
    routeData.Values.Add("controller", "ErrorController");
    routeData.Values.Add("action", "HandleTheError");
    routeData.Values.Add("error", exception);

    Response.Clear();
    Server.ClearError();

    IController errorController = new ErrorController();
    errorController.Execute(new RequestContext(
        new HttpContextWrapper(Context), routeData));
}
Michel van Engelen
  • 2,791
  • 2
  • 29
  • 45
4

Normally when I get this, it's because I've forgotten to add the following into the Web.config when deploying to IIS6 after developing on IIS7 (or the IIS Express 7 that comes with Visual Studio):

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
Nathan Phillips
  • 11,899
  • 1
  • 31
  • 24
3

The blank page is shown when errors occur in particular places - in my case it was a MethodNotFoundException...

To see the error, make sure you enable "HTTP Errors" and "HTTP Redirection" services in the "Web Server (IIS) role.

Lars Corneliussen
  • 2,513
  • 2
  • 26
  • 36
2

I solved the issue, the major issue was the different versions of MVC framework. Production Server was having MVC Beta while i have installed MVC RC1. So as soon as i installed the RC1 on the server as well as run the mvc extension registeration scripts, everything worked Thanks for your help guys

Gripsoft
  • 2,570
  • 7
  • 27
  • 30
  • what do you mean by registration scripts. I have the blank page on my current production and staging server after deployment. Both have mvc3 installed. – Guillaume Schuermans Apr 13 '12 at 14:36
0

This means you have an Exception thrown in your MVC application but you likely have a class in your MVC that's capturing, filtering, and hiding those exceptions. Those exceptions are still thrown but you cant see whats causing them. MVC still reroutes the page request but returns nothing because of the hidden exceptions. You cant stop the problem until you see the exceptions being thrown. You cant see the exceptions in the web page until you turn off MVC's exception handing filters.

One thing that might be preventing you from seeing the exceptions is a GlobalFilterCollection called via an MVC filter in the global.asax when the website first loads. You can normally find these calls in the Global.asax file. That file generally calls the HttpApplication object when the website first loads and its events. In its events it then loads in the default MVC routes developers add, but can also load filters that process site-wide exception handling. Developers often stuff Exception handling via filters in the global.asax thinking they are intelligently handling exceptions and issues from the user, but which is a mistake. If you find a filter in there just comment them out. Suddenly all your errors will appear in your HTML page again once you do.

You can then troubleshoot the problem! Good luck!

Stokely
  • 12,444
  • 2
  • 35
  • 23
0

This was also happening to me when:

1) I added a CompressAttribute to add Gzip when the browser accepts it.

response.AppendHeader("Content-Encoding", "gzip");
                    response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);

2) I was modifying the output HTML to change the displayed phone number:

response.Filter = new OutputHtmlReplacer(response.Filter, phoneNumber);

where OutputHtmlReplacer is a class that inherits from MemoryStream

So, the solution was:

1) Verify the headers and check if we are applying compression.

2) If so, then the new OutputHtmlReplacer response filter has to be wrapped by the GzipStream.

Francisco Goldenstein
  • 13,299
  • 7
  • 58
  • 74
0

Justin case that anyone is hitting the same issue as I had, try to monitor:

protected void Application_Error(object sender, EventArgs e) {

For me the application was failing silently and I did not know, so obviously it was returning a blank, but the confusing part was returning a 200 as http response status code.

Anyhow, I hope this helps someone in the future.

0

What's the server environment? If it's not IIS7/Server 2008 there are other tweaks you have to do to get the routing to work correctly, although if that's the case you would probably get an error page, not a blank page.

Jason
  • 86,222
  • 15
  • 131
  • 146
0

If it's the production server that is having the problem, it is probably the role permissions. You need to make sure that all of the folders and files your application is using allow reading (and in some cases writing if your using logs) to the role identity that IIS is using.

Usually the identity IIS is using is in Web Site Properties -> Directory Security -> Edit (Authentication and access control). If you don't want to allow any computer on your network to access the website then you should probably turn off "Enable anonymous access". If you do want to allow this though, this will be the identity you need to give access to in your webapp folders and files. Otherwise you may need to give access to the role which contains the user identities you want to have access.

Daniel
  • 1,231
  • 3
  • 15
  • 20
  • I understand your point, but i am not using any authentication as i even disabled the authentication via web.config and only authentication i needed is to run db instance. I am not using any logging as well – Gripsoft Feb 17 '09 at 18:19
  • I think that maybe IIS authentication is something apart from the authentication settings in web.config, though I'm not sure. I think it's at least worth a try to turn on anonymous access in IIS and add that identity to the webapp folders and files. – Daniel Feb 17 '09 at 18:26
  • If it still doesn't work with those settings, then I'm not sure what else it could be because I've only seen a blank page as your describing when I had permission settings issues. – Daniel Feb 17 '09 at 18:29
0

From the looks of it I would expect that the first route would work if you were going to a url like /Home.aspx but if you are just going to the / url then ASP.net does not know how to handle the URL. It will try and match on IIS defaults pages like index.html, default.aspx, index.aspx, etc. If nothing is found then the request isn't getting anywhere. Trying creating a default.aspx (or any other index file in the route), then in the page_load do a response.redirect("~/Home.aspx").

If that doesn't work I would check out this source. One of the main reasons IIS 6 and MVC don't play nice is that IIS 6 by default does not have the wild card * mapped to the ASP.net dll.

I am sure it is a way that the product server is configured, can you do any comparison between your XP instance and production?

Kyle LeNeau
  • 1,038
  • 2
  • 12
  • 19
0

Do you have HTTP Handlers and Modules defined in web.config on production server?

    <httpHandlers>
        <remove verb="*" path="*.asmx"/>
        <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
        <add verb="*" path="*.mvc" validate="false" type="System.Web.Mvc.MvcHttpHandler, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpHandlers>
    <httpModules>
        <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>

On IIS6, URLs must contain .mvc (eg. /Products.mvc/ListAll). Check these guides for proper IIS 6 configuration and .mvc extension workaround:

Deploying ASP.NET MVC to IIS 6

Using ASP.NET MVC on IIS 6 without the .MVC Extension

Jozef Izso
  • 1,740
  • 15
  • 22
0

Try deleting the app_offline.htm file if it is being created in your Application.

0

As another possible solution:

I had not deployed for a month or so, but had updated my Visual Studio by a few minor releases. A incompatibility crept in between VS Base and some of my Nuget packages. Updated my packages, made sure to clean (and delete bin/obj - even though it did not initially solve the problem) and then redeployed. Worked thereafter.

Anthony Horne
  • 2,522
  • 2
  • 29
  • 51