-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.

1
  • Follow any tutorial. You probably don't know whats going on. Commented Sep 1, 2022 at 13:38

2 Answers 2

1

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();
    }
Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.