0

I have two applications:

  • X.Web - Asp.net core 1.1 web application
  • X.Api - ASP.NET WebApi2 application in .NET 4.6.1

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

vanpersil
  • 764
  • 1
  • 8
  • 26

1 Answers1

1

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?

Daboul
  • 2,635
  • 1
  • 16
  • 29
  • Yes - you understood it perfectly. I am using IIS 8.5 on both test and prod environment. 1, 2) - i dont think so (but not 100% sure). When both application were in their folders I could invoke Api from postman. As an experiment I COPIED the content from X.Web to the root folder and API stopped responding - every postman request was rejected. When I simply deleted the copied files, Api started to respond again to my postman requests. 3) I will definitely try the URL Rewrite module Thank you. – vanpersil Jun 27 '17 at 09:13
  • I checked URL Rewrite - it works perfectly, thank you for your hint – vanpersil Jun 30 '17 at 07:33
  • No worries, it's a nice tool to have in your 'Répertoire', can be useful in numerous occasion. I'm currently using it to simulate a load balancer. – Daboul Jun 30 '17 at 09:27