1

I know there are a million similar/same questions here (I know that because I've read them) but I just can't figure out why my default document is not displaying. It used to; and if I enable the default web-site then that site's default page is displayed. The HTTP error code is 404.

EDIT: Is it because I'm using "localhost" or top level domain? That is https://localhost/MyDefault.html works but I get a 404 from https://localhost.

I believe/guess something in the following is the issue. It used to work: -

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <defaultDocument enabled="true">
      <files>
        <clear />
        <add value="MyDefault.html" />
      </files>
    </defaultDocument>
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>

I was looking for 2 days then came across what I thought was the solution but sadly (as fitting as it sounds) it doesn't work :-(

FYI this is a SPA/PWA and when I say mvC it really is Controller only.

Here's the Global.asax part.

public class MvcApplication : System.Web.HttpApplication
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("");

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

    }
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }
}

There is no HOME controller available.

This is the standard error page returned: - Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.3752.0

No files created in FRL

Failed Request Logging

IIS logging

This is the 404 error: - 2019-12-04 03:55:34 ::1 GET / - 443 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/78.0.3904.108+Safari/537.36 - 404 0 0 4

Here's the FRT request summary. The complete trace can be found at Complete FRT

enter image description here

[4]:

McMurphy
  • 1,235
  • 1
  • 15
  • 39
  • 1
    Before claiming something doesn't work, run some basic diagnostics like FRT, https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis – Lex Li Dec 03 '19 at 01:25
  • What is version of MVC & IIS? – Pranav Singh Dec 03 '19 at 04:05
  • IIS 10 Windows 10 .Net 4.7.2 outputs a class library – McMurphy Dec 03 '19 at 05:17
  • @lex Li I enabled Failed request logging for my site which created the directory by I'm not getting any files created. – McMurphy Dec 03 '19 at 07:01
  • Oh and MVC version 5.2.7.0 – McMurphy Dec 03 '19 at 07:15
  • I tried your configuration and it seems works fine on my side. Please enable Failed request tracing and IIS log. Please post its sub-status code because it seems not to be a simple 404.0 error. Besides, what handler returned this error? Please post more detail information. If the error code is 404.0, please try process monitor to trace the IO status. It will tell us what file it is reading. – Jokies Ding Dec 03 '19 at 08:37
  • I've posted the little log info that seems available. Can @Jokies Ding please post your web.config as an answer? And thanks for your help! – McMurphy Dec 04 '19 at 04:14
  • @McMurphy Have you created FRT rule for 404.0 error? Its very strange that IIS return 404.0 error. So its very important to know which handler returned this error. If the error returned from default document, then we need to use Process monitor to trace access denied error or file not found error. But it looks just like your application is still trying to load index from an unavailable Home controller. – Jokies Ding Dec 04 '19 at 06:21
  • @Jokies Ding thanks for sticking with this! Yes, stupid me, I didn't have a rule configured but now I have shed loads of trace and not sure where to look? Have attached the hopefill relevant 404s above. – McMurphy Dec 04 '19 at 08:30
  • @McMurphy Did you upload the full FRT log? Your post log just show IIS return 404 error directly. You could open the .xml file via IE and you will see the full formatted html report. Besides, could you get default document work with a simple web website? If what you posted are the full FRT log, I think there must be something wrong with your IIS pipeline. – Jokies Ding Dec 04 '19 at 08:51
  • No just 404 snippets. The Full FRT log is quite big. Can I filter on just WWW failures or do you need to see ISAPI as well? Also I changed the default "Home" "Index" to an existing controller/action and that didn't change things. I will post full log as answer tomorrow unless you can tell me what to look for? – McMurphy Dec 04 '19 at 12:16
  • I've created a shareable link for the whole file: https://drive.google.com/open?id=1lTv9hpkk2-kyWXne7NpdBnDstHWgJ-uX I'll update the edge summary in the main question body. Thanks @Jokies Ding – McMurphy Dec 05 '19 at 00:41
  • @McMurphy Inaddition, please remember to remove the link of your FRT log. Since it is not sure if it will expose some sensitive information of your web application. – Jokies Ding Dec 05 '19 at 08:07

1 Answers1

1

My reply is too long so I can't post it in comment. I reviewed your log and notice that 404 come from asp.net managed pipeline.And Static file handler even not get involved in this request.

So I think there could be something wrong with your project or extensionless handler ExtensionlessUrlHandler-Integrated-4.0. enter image description here

First of all, we need to check whether the routes.ignoreroute works fine in visual studio. Did you get 403.14 even there’s no Mydefault.html in your project’s root folder?

Because I notice that you are registering RouteConfig.RegisterRoutes(RouteTable.Routes) in global.asax but you didn't include it into RouteConfig class. I am used to create separate Route.config to store the route table.

If it works fine in VS, have you tried to clean all release files in the root folder and re-publish via VS deployment tool? Did you see staticfile handler in IIS manager handler mapping? Besides, please check whether your application pool identity and IUSR have permission to access Your website's root folder. Since this is not a typical 404 error, we may have to troubleshooting step by step.

Edit: enter image description here

Jokies Ding
  • 3,374
  • 1
  • 5
  • 10
  • Please see in my web.config where I remove and install all the handlers ExtensionlessUrlHandler-* IIRC this may have been because of OPTIONS pre-flight but regardless it was *necessary* to get my Ajax "data/getFromDB" actions being found and working correctly. Others posts have mentioned doing the same with the static file handler but this once again causes my relative controller URLs to fail. I am using the ApplicationPoolIdentity. When I substitute routing to Home/Index controller with one that exists it doesn't get called. It does NOT work in VS either. I publish via Build-->Publish. – McMurphy Dec 05 '19 at 06:53
  • @McMurphy Did you see your handler orderred like my post above? If your route table didn't even bring your index 403.14 in visual studio, then it shouldn't be an IIS issue. Besides, have you modified your global.asax you posted before? If you didn't place RegisterRoutes under RouteConfig class. Then you should just register RegisterRoutes(RouteTable.Routes) in Application_Start() instead of RouteConfig.RegisterRoutes(RouteTable.Routes); – Jokies Ding Dec 05 '19 at 07:38