IIS MVC web app gets 404.0 error when opening first view page

Jay Gunderson 0 Reputation points
2025-02-14T17:50:30.9833333+00:00

I built an MVC web application (about a dozen view pages) that is working fine when run from the VS.net 2019 designer IIS Express, but when I deploy the app to local IIS and run it, I get error...

HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

After weeks of checking every issue I can find, I have to ask for help form the folks here - what am I missing? Here are the steps my app uses to get its first web page to be reached...

I have index.html at the myApp home directory which invokes the first view page...

var host = window.location.host;

var protocol = window.location.protocol; 

var url = protocol + "//" + host + "/myAppLogin/Login"; 

//alert("url: " + url); 

window.location.replace(url); 

Here is my RouteConfig.cs...

namespace myApp

{

public class RouteConfig 

{ 

    public static void RegisterRoutes(RouteCollection routes) 

    { 

        routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

        routes.IgnoreRoute("");  



        routes.MapRoute( 



            name: "Default",  

            url: "{controller}/{action}/{id}",                

            defaults: new { controller = "myAppLogin", action = "Login", id = UrlParameter.Optional } 

        ); 

    } 

} 

}

The myApp properties in VS.net designer shows start action specific page with index.html shown.

I copy the entire project over to C:/inetput/wwwroot

In inetMgr I startup myApp and check bindings and settings, all looks ok on port 80 (default Web Site shut down)

Next I issue this in my web browser - http://localhost/myApp/index.html which gives error...

HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

the 404.0 error page shows RouteConfig.cs did its job correctly...

Requested URL http://localhost:80/myAppLogin/Login

Physical Path C:\inetpub\wwwroot\myApp\myAppLogin\Login Logon

Method Anonymous

Logon User Anonymous

Some other settings that might be appropriate...

Windows 11 pro IIS version 10.0.26100.1 DefaultAppPool .net CLR version v4.0 identity is NetworkService

myApp .net CLR version is v4.0 and identity is NetworkService

myApp web site has physical path C:\inetpub\wwwroot\myApp defaultAppPool and pass-through authentication.

Thanks for any help.

Jay

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,600 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 71,586 Reputation points
    2025-02-16T16:38:57.93+00:00

    You appear to configured you website as an application directory rather than root site. If the url to the index is:

    http://localhost/myApp/index.html

    then the login route is:

    http://localhost/myApp/myapplogin/login

    Your JavaScript needs to add the application directory name part of the path. A common approach is to set the base href in document.

    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base

    Then in JavaScript do:

    window.location.replace(“/myapplogin/login”);
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.