【发布时间】:2017-03-02 11:57:16
【问题描述】:
简体Startup代码:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "",
defaults: new { controller = "Main", action = "Index" });
});
}
在 Visual Studio 2015 中运行应用程序后,我在浏览器中看到“localhost:xxx”,但没有看到 MainController.Index() 的结果。只是空白页。我错过了什么?
更新:
Web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
更新 2:
问题来自于对控制器的依赖注入服务中的异常,并且因为我忘记使用开发人员异常页面站点刚刚返回空白页面给我。所以对于不正确的问题我很抱歉,但在我的情况下路由很好。
【问题讨论】:
-
检查我的答案,如果对你有帮助,请告诉我!
标签: c# .net routing asp.net-core