[英]How to render index.html file that is in wwwroot folder using controller or view in ASP.NET Core MVC
我有一個index.html
文件存儲在wwwroot
文件夾中,但我想通過使用來自 controller 或視圖的重定向從視圖或 controller 以外的任何方式訪問它。
as you decribed,the index.html is a staticfile that could be accessed with uri like: https://localhost:5001/index.html, controller is not necessary. 如果你想在你的視圖中渲染它,你可以試試<iframe src=~/index.html></iframe>
您只需添加行app.UseDefaultFiles();
在配置方法中的startup.cs
中。
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseHttpsRedirection();
app.UseDefaultFiles(); // this line of code.
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.