vanpersil
vanpersil

Reputation: 804

How to configure IIS server to host two applications one of which should be default

I have two applications:

Now they are both available as www.example.com/X.Web and www.example.com/X.Api respectively. My customer wants the web application to be available simply as www.example.com.

I tried a quick solution in my test environment - I just moved the content of X.Web folder to wwwroot and without any problems everything worked fine.

However, on my production server the web app works - htmls, scripts and styles are loaded correctly, but X.Api stops working - i get response

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"         
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <title> IIS 502.5 Error </title>
        <style type="text/css"></style>
    </head>
    <body>
        <div id = "content">
            <div class = "content-container">
                <h3> HTTP Error 502.5 - Process Failure </h3>
            </div>
            <div class = "content-container">
                <fieldset>
                    <h4> Common causes of this issue: </h4>
                    <ul>
                        <li> The application process failed to start </li>
                        <li> The application process started but then stopped </li>
                    <li> The application process started but failed to listen on the configured port </li>
                </ul>
            </fieldset>
        </div>
        <div class = "content-container">
            <fieldset>
                <h4> Troubleshooting steps: </h4>
                <ul>
                    <li> Check the system event log for error messages </li>
                    <li> Enable logging the application process’ stdout messages </li>
                    <li> Attach a debugger to the application process and inspect </li>
                </ul>
            </fieldset>
            <fieldset>
                <h4> For more information visit:              
                    <a href="https://go.microsoft.com/fwlink/?linkid=808681">
                        <cite> https://go.microsoft.com/fwlink/?LinkID=808681 </cite>
                        </a>
                    </h4>
                </fieldset>
            </div>
        </div>
    </body>
</html>

for each and every request. In my Event log I can see:

Application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE/X.API' with 
physical root 'C:\inetpub\wwwroot\X.Api\' failed to start process 
with commandline '"dotnet" .\X.Web.dll', ErrorCode = 
'0x80004005 : 80008081.

The questions are: 1) what can be a problem 2) Why in the event log I can see ...failed to start process with commandline '"dotnet" .**X.Web.dll**... 3) Is there any other way to achieve this simple requirement of my client

Upvotes: 0

Views: 178

Answers (1)

Daboul
Daboul

Reputation: 2733

So, just to make sure I understand you properly, initially, you had: www.example.com/X.Web and www.example.com/X.Api, and X.Web was calling X.Api, right? Then you moved X.Web files from wwwroot/X.Web to wwwroot directly, and it worked on your env but not on the production env? Which version of IIS are you using?

1/ Maybe an idea: by moving X.Web maybe you have changed the user under which your X.Web application was running, making it unable to launch your ASP.NET Core application.

2/ My suggestion to 1 could explain, credentials issues.

3/ I would definitively avoid putting the file of X.Web directly under wwwroot and instead I would configure IIS to get a redirection from www.example.com to www.example.com/X.Wep. You could use URL Rewrite module (maybe an overkill in that case but it's a module that is very good to know in my opinion because it can help in various scenario) or simply configure IIS to redirect, this SO thread could be helping How to redirect a URL path in IIS?

Upvotes: 1

Related Questions