0

I have several action methods that can use the same view. I've tried calling View with eg

return View("~/views/contact/Emails", model);

The view "Emails" exists in the specified directory (Resharper underlines the URL), but when I run the application I get the error "The view '~/views/contact/Emails' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/views/contact/Emails"

1 Answer 1

0

Assuming you're inside ContactController, you can simply pass in the name of the view.

return View("Emails", model);

MVC uses routing to find Views, so it doesn't care about the file path, just the name (at least at this point in the request pipeline).

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

1 Comment

That does the trick. Just using the name of the view works. Which suggests that the response at stackoverflow.com/questions/5938837/… is wrong.

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.