1
votes

I have hosted many ASP.NET and MVC applications before. I was playing with MVC6 lately and tried to host an MVC6 application.

Everything works fine if I host it as a new website. When I host it as an application under the default website of IIS, it only shows an empty page. Please find the log information below

warn: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0] Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits. warn: Microsoft.AspNet.DataProtection.Repositories.EphemeralXmlRepository[0] Using an in-memory repository. Keys will not be persisted to storage. Hosting environment: Production Now listening on: http://localhost:23000 Application started. Press Ctrl+C to shut down. info: Microsoft.AspNet.Hosting.Internal.HostingEngine[1] Request starting HTTP/1.1 GET http://localhost/MVC6 info: Microsoft.AspNet.Hosting.Internal.HostingEngine[2] Request finished in 0.0687ms 404

Note: Default website uses application pool asp.net4.5 and my MVC6 application uses it's own application pool as mentioned in http://docs.asp.net/en/latest/publishing/iis.html#iis-server-configuration

Anyone else faced similar problem like this? I want to know how to make it work under default website

1

1 Answers

0
votes

Edit: This is a bug in vs2015 rc1 https://github.com/aspnet/Hosting/issues/416#issuecomment-149046552.

There is a workaround for this bug in above link but I followed a different method because I need to host my application in more than one website without republishing.

I resolved the above problem using the Route attribute. After adding the route attribute to an action result, application works fine

public class HomeController : Controller
    {
        [Route("MVC6")]
        [Route("")]
        public IActionResult Index()
        {
            return View();
        }    
    }