在默认网站下托管 MVC6 应用程序
Hosting an MVC6 application under default website
我之前托管过许多 ASP.NET 和 MVC 应用程序。我最近在玩 MVC6 并尝试托管 MVC6 应用程序。
如果我将其托管为新网站,一切正常。当我将其作为 IIS 默认网站下的应用程序托管时,它只显示一个空白页面。请在下面找到日志信息
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
注意:默认网站使用应用程序池asp.net4.5而我的MVC6应用程序使用它自己的应用程序池如http://docs.asp.net/en/latest/publishing/iis.html#iis-server-configuration
中所述
还有其他人遇到过类似的问题吗?我想知道如何让它在默认网站下工作
编辑: 这是 vs2015 rc1 https://github.com/aspnet/Hosting/issues/416#issuecomment-149046552 中的错误。
上面 link 中有一个针对此错误的解决方法,但我采用了另一种方法,因为 我需要在多个网站上托管我的应用程序而不重新发布 。
我使用 Route 属性解决了上述问题。将路由属性添加到操作结果后,应用程序工作正常
public class HomeController : Controller
{
[Route("MVC6")]
[Route("")]
public IActionResult Index()
{
return View();
}
}
我之前托管过许多 ASP.NET 和 MVC 应用程序。我最近在玩 MVC6 并尝试托管 MVC6 应用程序。
如果我将其托管为新网站,一切正常。当我将其作为 IIS 默认网站下的应用程序托管时,它只显示一个空白页面。请在下面找到日志信息
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
注意:默认网站使用应用程序池asp.net4.5而我的MVC6应用程序使用它自己的应用程序池如http://docs.asp.net/en/latest/publishing/iis.html#iis-server-configuration
中所述还有其他人遇到过类似的问题吗?我想知道如何让它在默认网站下工作
编辑: 这是 vs2015 rc1 https://github.com/aspnet/Hosting/issues/416#issuecomment-149046552 中的错误。
上面 link 中有一个针对此错误的解决方法,但我采用了另一种方法,因为 我需要在多个网站上托管我的应用程序而不重新发布 。
我使用 Route 属性解决了上述问题。将路由属性添加到操作结果后,应用程序工作正常
public class HomeController : Controller
{
[Route("MVC6")]
[Route("")]
public IActionResult Index()
{
return View();
}
}