Blazor,将主页设置为html页面 [英] Blazor, set home page to an html page
问题描述
我有一个blazor应用程序,但它分为两部分. -具有多个网页的网站 -Blazor应用程序
I have a blazor app, but it is divided in 2 parts. - a web site with several web pages - a Blazor Application
默认情况下,我希望导航到"index.html"页面.这将有一个登录"链接 将会重定向到主应用程序页面.
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.
如何执行此操作...默认情况下,我被定向到index.cshtml(即blazor应用程序)?
How can I do this... by default I'm directed to the index.cshtml (ie. the blazor app) ?
推荐答案
我希望导航到"index.html"页面.
I wish to navigate to the "index.html" page.
假设您已将index.html
放在wwwroot/
文件夹中,则可以通过注册DefaultFiles中间件来实现:
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)
或者如果要将index.html
放在其他位置,则可以传递自定义FileProvider
(例如官方文档.
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.
这篇关于Blazor,将主页设置为html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!