1

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.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

1

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>

Ruikai Feng
  • 6,823
  • 1
  • 2
  • 11
0

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();
    }
Hamza Amin
  • 11
  • 2