Martin Andersen
Martin Andersen

Reputation: 2730

Can I serve a static html page from mvc

I would like to be abel to run my angularjs app from the app directory from VS code without using VS2015 and without running iis express. This will make it possible to create new UI very fast specially combined with mocking the service layer.

It's a mvc5 + webapi2 application.

So I need to run /app/index.html from mvc. The index.html is a full html page not an angular template.

Upvotes: 2

Views: 3052

Answers (3)

PSo
PSo

Reputation: 1008

2 ways of doing so:

i. Simple replace the original index.html to your new index.html, all other libraries please place in side the corresponding folder.

ii. in web.config, you may change the maproute properties, you can map your view as default or add new map route.

Thank you.

Upvotes: 1

Dennis Nerush
Dennis Nerush

Reputation: 5663

You can simply call: return Redirect("~/path/to/.html");

Upvotes: 2

Language Lassi
Language Lassi

Reputation: 2630

Create an action method that returns perticular HTML file. You can return File from controller action. have a look:

public ActionResult Index()
{
    var result = new FilePathResult("~/Html/index.htm", "text/html");
    return result;
}

Also check this Class: FileResult

Hope this helps!

Upvotes: 3

Related Questions