Home > Net >  How to render index.html file that is in wwwroot folder using controller or view in ASP.NET Core MVC
How to render index.html file that is in wwwroot folder using controller or view in ASP.NET Core MVC

Time:09-02

I have an index.html file stored in the wwwroot folder but I want to access it from view or controller outside any way by using redirect from controller or view.

CodePudding user response:

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. If you want to render it in your view,you could try <iframe src=~/index.html></iframe>

CodePudding user response:

You just have to add the line app.UseDefaultFiles(); in startup.cs in Configure method.

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.UseHttpsRedirection();
        app.UseDefaultFiles();     // this line of code.                                  
        app.UseStaticFiles();
        app.UseCookiePolicy();

        app.UseMvc();
    }
  • Related