ForeverNoobie
ForeverNoobie

Reputation: 531

How to have a simple .html page in Asp.net MVC

I want to add an html page that's accessible with www.myhost.com/mypage.html into my ASP.net MVC project. I know the norm is to use controllers and cshtml views but I do have a good reason for wanting to include a simple .html page.

Upvotes: 0

Views: 2708

Answers (2)

AJ McK
AJ McK

Reputation: 215

You can include a simple .html page with no problem, and if it's a static landing page, you can just create a specific route for that request, so the output mirrors www.myhost.com/mypage.html".

Upvotes: 1

Patrick Hofman
Patrick Hofman

Reputation: 156978

Just create a html file in a separate folder (SomeFolder in the sample), and then configure the routing to ignore it. You will need this most of the time, since usually all requests are handled by ASP.NET MVC (so the static file handler won't pick them up, like it normally does).

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("SomeFolder/{*pathInfo}");

    // your other routes
}

Upvotes: 3

Related Questions