Ropstah
Ropstah

Reputation: 17794

ASP.NET MVC How to specify which folder the View pages reside in?

by default the ASP.NET MVC engine searches the following folders for View pages:

However I want to put some of my View pages like this:

How can I let the engine look for this?

Upvotes: 43

Views: 47717

Answers (2)

Ofigenn
Ofigenn

Reputation: 131

You have to create a class derived from IViewEngine interface and register this class in Aplication_Start event in Global.asax.cs Check this link text, but there are some differences with 1.0

Upvotes: 8

Kailas Mane
Kailas Mane

Reputation: 1935

You can return view placed in custom sub-folders, from controller action by, giving out full view path in return statement,

ex.

public ActionResult Create()
{
    return View("~/Views/ProEnhance/Employee/Create.cshtml");
}

here,

ProEnhance - user defined folder

Employee - Controller Name

Create - action Name

Upvotes: 78

Related Questions