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.
How to render index.html file that is in wwwroot folder using controller or view in ASP.NET Core MVC
Asked
Active
Viewed 1,591 times
1

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

Zain Haider
- 11
- 2
-
Follow any tutorial. You probably don't know whats going on. – daremachine Sep 01 '22 at 13:38
2 Answers
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