I have a Test.cshtml view where I have the ability to code something like:
@Url.Action(.....)
It works when the page is located under the Views folder.
It doesn’t work anymore when the page is located elsewhere like under Themes folder.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s normal. Views should be located only inside the Views folder. They have nothing to do outside it.
The reason for this is the
~/Views/web.configfile which indicates the type of all views:Notice the
pageBaseTypeattribute? This is what indicates that a view derives from theSystem.Web.Mvc.WebViewPageclass which defines properties such as Html and Url helpers.When you put a view somewhere outside the Views folder, I suppose you forgot to include such a web.config at the root so there is nothing specifying the base type of your razor pages and thus things like Url and Html helpers no longer exist.
So one possibility is to violate all standard ASP.NET MVC conventions and copy the
~/Views/web.configfile to wherever you intend to place your views.