I have a pretty basic question, but I cannot find the answer online without resorting to asking it myself. In an ASP.NET MVC 2 WebSite, if I have a Shared view located in a Shared folder. Let's say the view is called Error,开发者_Go百科 where is the controller for this View? Do I create a SharedController?
You don't create a SharedController
. In any controller you want the view available, either create a Method called Error
or have a Method return View("Error")
.
Basically if MVC can't find the View in the Controller Named Directory it looks in the Shared folder for it (which also works for Partial Views and Controls).
精彩评论