We have a MVC 2.0 / c# 4.0 application that we develop visual studio. We have a part of the site (admin) that we have put in it's own sub directory and with its own routing rules:
routes.Add("DomainRoute", new DomainRoute(
ConfigurationManager.AppSettings["adminDomain"], // Domain with parameters
"{controller}/{action}/{id}", // URL with parameters
new { controller = "AdminPage", action = "Admin", id = "", isAdmin = true }
We have all the views for the admin site inside an admin sub folder so that you get paths like: \views\admin\auth\login.aspx
In the \co开发者_如何学JAVAntrollers\admin\authController.aspx file I have a function called login:
public ActionResult Login()
{
return View();
}
This works just as it should, ie if i go admin.localhost\auth\login I go to the login page. But if I do a right click in visual studio and "go to view" i get an error "unable to go to matching view". Is there anyway to solve this?
You should really be using an Area for this. They handle this concept really nicely, and VS will know where to find your views.
However, if you are using ReSharper it will not be able to resolve your .cshtml Views until version 6 (.aspx Views seem to work fine).
精彩评论