asp.net-core - Blazor, set home page to an html page
问题描述
I have a blazor app, but it is divided in 2 parts. - a web site with several web pages - a Blazor Application
By default, I wish to navigate to the "index.html" page. This one will have a "login" link that will redirect to the main application page.
How can I do this... by default I'm directed to the index.cshtml (ie. the blazor app) ?
解决方案
我希望导航到“index.html”页面。
假设您已将 放在index.html
文件wwwroot/
夹中,您可以通过注册 DefaultFiles 中间件来实现:
app.UseDefaultFiles(); //在调用 app.UseStaticFiles() 之前添加这一行; app.UseStaticFiles(); ...
(注意中间件的顺序很重要)
或者如果你想放在index.html
不同的位置,你可以传递一个自定义FileProvider
(例如PhysicalFileProvider)。更多详细信息,请参见官方文档。