0

I am new to .Net and using .Net core to create simple web app. It using Razor pages for views and its static contents for now.

Here is the project structure,

enter image description here

I can use only .cshtml files for the navigations, like

    https://localhost:44391/Home //goes to Home.cshtml

    https://localhost:44391/About //goes to About.cshtml

I have a static html file and some required assets placed inside the subfolder called "Off" in Pages folder.

https://localhost:44391/Off

I know, I can use Razor page itself. But here I downloaded some third party integration and it provides this and asked me to access in the same hierarchy with html page.

May I know is this possible?

2
  • Are you asking how to route to that specific html file? Commented Oct 8, 2020 at 13:22
  • 1
    If the content in Off is static, you want to put Off in the wwwroot folder. Commented Oct 8, 2020 at 14:00

2 Answers 2

2

I have a static html file and some required assets placed inside the subfolder called "Off" in Pages folder.

https://localhost:44391/Off

You can try to call app.UseFileServer to enable the serving of static files.

//...

app.UseStaticFiles();


app.UseFileServer(new FileServerOptions
{
    FileProvider = new PhysicalFileProvider(
        Path.Combine(env.ContentRootPath, "Pages/Off")), 
    RequestPath = "/Off"
});


app.UseRouting();

//...

Test Result

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

Yes, it is possible, you can try to include your html page content as a partial view:

@Html.Partial("~/Pages/Off/index")

This is in the case that you just want to show the html page content in your MVC website. If that third party integration requires something special then we will need further explanation of the scenario.

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.