简体   繁体   中英

ASP.NET Forms application displays blank “default.aspx” page sporadically instead of loading/showing contents

I have an ASP.NET Forms application, Framework version 4.5, IIS 7.5 in Windows 2008 Server R2 Standard. Sporadically I get a blank page(screenshot below). When I reset the website in IIS the problem gets fixed.. but then happens again in 2/3 days. Web.config file contains "default.aspx" on top as the default document.

In my application, default.aspx is an empty file that gets created on applications start-up - doesn't contain any code/content in it. My guess is that IIS keeps the blank page in cache and delivers the blank page sometimes. All other pages in the solution are virtual pages without physical existence. However, hitting other URLs loads the contents correctly.

I have already made the following attempts that did not solve the problem:

  1. IIS output caching - Prevent all caching for both user-mode and kernel-mode.
  2. Added following code block in Global.asax in order to fix the issue to load default document

     protected void Application_BeginRequest(Object sender, EventArgs e) { var app = (HttpApplication)sender; if (app.Context.Request.Url.LocalPath.EndsWith("/")) { app.Context.RewritePath(string.Concat(app.Context.Request.Url.LocalPath, "default.aspx")); } } 

Can someone come up with some clue? Thanks in advance :)

Screenshot of the blank page

I think the issue occurs because of the way application is designed in regards to virtual pages. There is a "default.aspx" virtual page in the application as well as a static file (which is just an empty file) with the same name in the root folder. My best guess is the handler sometimes deliver the static page instead of the virtual page, and therefore, the blank screen is displayed.

I've deployed a work around where I replaced the static file default.aspx with index.html. Just to be sure to redirect to default page in case the index.html file is loaded, following piece of codes added:

    <meta charset="UTF-8">
    <meta http-equiv="refresh" content="0; url=default.aspx" />

    <script>
        window.location.href = "default.aspx";
    </script>

So far it looks good but I will keep an eye on the application's behavior.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM