开发者

ASP.NET MVC 2.0: Shared View Controller

开发者 https://www.devze.com 2023-04-05 01:49 出处:网络
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 t

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消