0

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, where is the controller for this View? Do I create a SharedController?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Hmmm.. What if I want the view to be available in ALL controllers? Can I just create the Method in a base controller and have them all inherit?
That certainly is one way to go about it. I never had a need for that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.