IIS and Asp.net Core error 404 issues

Michael Mastro II 56 Reputation points
2022-03-02T03:20:17.833+00:00

Good evening,

I suspect that I have something setup incorrectly, but have not been able to pin it down. I have an IIS server with two sites set up on it. Site named Main points to E:\Main and is bound to ports 80 and 443. When I enter www.mydomain.com in the browser it brought up the default IISstart page. I have a second site named api bound to different ports. That is mapped to E:\Api. I have three existing Asp.Net Core 3.1 applications that are also on the Main site. So if I browse to www.mydomain.com/app1 it brings up the application and there is no issues.

I published two asp.net core 3.1 applications using Azure DevOps Server 2020 using the IIS Web Manage and IIS Web Deploy tools for each of them. They go to the respective folders correctly but I am constantly getting 404 errors and the Javascript cannot be found, so there is a loss of functionality. I tried first this, which publishes correctly but leads to the 404 errors:

steps:
- task: IISWebAppManagementOnMachineGroup@0
  displayName: 'IIS Web Api Manage'
  inputs:
    EnableIIS: true
    WebsiteName: Api
    WebsitePhysicalPath: 'E:\Api'
    CreateOrUpdateAppPoolForWebsite: true
    AppPoolNameForWebsite: ApiAppPool
    DotNetVersionForWebsite: 'No Managed Code'

I then tried this but this will not start either application, and fails on publish for appcmd.exe errors:

steps:
- task: IISWebAppManagementOnMachineGroup@0
  displayName: 'IIS Web Api Manager'
  inputs:
    EnableIIS: true
    IISDeploymentType: IISWebApplication
    ParentWebsiteNameForApplication: Api
    VirtualPathForApplication: /
    PhysicalPathForApplication: 'E:\Api'
    CreateOrUpdateAppPoolForApplication: true
    AppPoolNameForApplication: ApiAppPool
    DotNetVersionForApplication: 'No Managed Code'
  enabled: false

error:

ERROR ( message:Cannot find SITE object with identifier "Api". )
##[error]Process 'appcmd.exe' exited with code '1168'.

The question is where am I going wrong?

Windows development Internet Information Services
Developer technologies ASP.NET ASP.NET Core
{count} votes

3 answers

Sort by: Most helpful
  1. AgaveJoe 30,126 Reputation points
    2022-03-02T12:04:22.9+00:00

    IIS allows shared hosting. Set the appropriate domain name in the site bindings for http and https. There's no problem hosting several domains on the same machine assuming you have DNS setup correctly.

    IIS 8.0 Server Name Indication (SNI): SSL Scalability

    179150-capture.png


  2. AgaveJoe 30,126 Reputation points
    2022-03-02T13:37:10.873+00:00

    The setting shows a domain (host name) is not configured as recommended. Typically each site has a domain. If you are hosting one site with multiple virtual directories then I assume you did not take this requirement into account when developing the applications. I'm guessing the css and js references are not pointing to the site's virtual directory or the files are missing entirely.

    The first step is verifying the files exist on the server in the expected directory. Next, review the URL causing the 404 and compare the URL to the expected virtual directory URL.


  3. AgaveJoe 30,126 Reputation points
    2022-03-02T18:27:40.467+00:00

    The configuration you shared does NOT have a host domain configured. Should we assume you have one domain??? My best guess is you created sub applications and the reference URLs do not match the actual resource location. Again, get the URL of the 404 error and verify it is correct. I suspect the URL is missing the application or virtual folder after the domain name but this is only a guess.


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.