Blazor, set home page to an html page

别来无恙 提交于 2020-04-30 06:44:06

问题


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) ?


回答1:


I wish to navigate to the "index.html" page.

Assume you have put the index.html within the wwwroot/ folder, you could achieve that by registering a DefaultFiles middleware:

app.UseDefaultFiles();    // add this line before invoking app.UseStaticFiles();
app.UseStaticFiles();

...

(Note the order of middlewares is important)

Or if you want to put index.html within a different location, you could pass a custom FileProvider (e.g. PhysicalFileProvider). For more details, see official docs.



来源:https://stackoverflow.com/questions/59513089/blazor-set-home-page-to-an-html-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!