我已经建立了一个空的WebAPI项目,其中.NET Core rc2
已与Angular2 rc1
连线。 Angular会处理所有相关的视图,并且WebAPI是后端。使用index.html作为默认页面的.NET Core rc2 WebAPI
当我在默认情况下启动应用程序时,它会从默认的API控制器提供localhost:4578/api/values
作为首页。
但是,我希望它显示index.html
默认位于wwwroot
和托管我的Angular2
应用程序。
在Startup.cs
的Configure
方法是这样的:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
app.Run(ctx =>
{
ctx.Response.Redirect("/index.html");
return Task.FromResult(0);
});
}
app.UseStaticFiles
和app.Run
拉姆达需要在地方手动重定向到index.html
工作,但它仍与/api/values
出来作为默认启动页面。
我知道,为了调试目的,我可以很容易地更改起始页面,但我想更改它,以便在我托管它时始终将index.html
作为起始页面。
我该如何改变这种情况?
我注意到,只是重定向到index.html。我几乎和你同样的观点,我想知道如何让它加载index.html作为默认路由。 – Samir
在我的情况app.UseDefaultFiles();显示错误?任何解决方案 –