Skip to content
This repository was archived by the owner on Dec 19, 2018. It is now read-only.

Host as sub application in IIS #813

Closed
sandves opened this issue Jul 13, 2016 · 3 comments
Closed

Host as sub application in IIS #813

sandves opened this issue Jul 13, 2016 · 3 comments

Comments

@sandves
Copy link

sandves commented Jul 13, 2016

I have recently migrated my application from RC1 to 1.0.0-preview2-final, and I am no longer able to host the app as a sub application under the main website like I was before ("corep" is the application I have migrated):

iis

After the migration, the web.config has moved from the wwwroot and up one level to the content root. Therefore, I changed the physical path of the IIS application accordingly. My web.config is listed below.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="dotnet" arguments=".\Corep.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
  </system.webServer>
</configuration>

I have the following code in my Startup.cs to enable hosting the application as a sub site.

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    app.Map("/corep", (app1) => this.Configure1(app1, env, loggerFactory));
}

public void Configure1(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
    app.UseApplicationInsightsRequestTelemetry();
    app.UseApplicationInsightsExceptionTelemetry();
    app.UseStaticFiles();
    app.UseMvc();
}

Application logs tells me that the application is running and requests are received, but every request result in a 404 response. Below is the output from the application when I try to access the index page.

Hosting environment: Production
Content root path: D:\Web\StoragePortal\Corep
Now listening on: http://localhost:9820/corep
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://{my-url}/corep/index.html  
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 160.1519ms 404 

Any ideas about how I can make this work?

EDIT: I just wanted to add that the application works perfectly if it hosted alone, and not as a sub application.

@Tratcher
Copy link
Member

The Map workaround it's no longer required for this scenario, try removing it.

@sandves
Copy link
Author

sandves commented Jul 13, 2016

That seemed to do the trick! Now I only need to fix URL rewriting to make the AngularJS work, but that is probably a different issue.

@Tratcher
Copy link
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants