I’m using the MVC model of ASP.NET. I’m working on creating the main master right now.
I created most of my stuff with good old HTML, except for the ContentPlaceHolders.
I created the hyperlinks with regular anchor tags. I created my various controllers and views for each of my main pages.
In the anchor tags, I placed the URLs that would be used for in HTML. For example, I have a page called “Register”, so I have a controller “RegisterController”, then it’s Index View.
My question is: The code editor tells me it can’t find the file in the href attribute. Is there a better way to do hyperlinks in ASP.NET, or do I just need to deal with those warnings?
Look at the Html.ActionLink method. It’s an extension method of the HtmlHelper class for views. For example, to link back to the homecontroller.index action…
<%: Html.ActionLink(“Back to Index”, “Index”, “Home”) %>
There are several overrides with all the needed parameters.
I’m learning ASP.net 4 as well, not the MVC part yet.
If you click on the C:\ part in the solution explorer and hit F4 it will bring up the properties window. Change the virtual path to a /, and make sure you point to the file path like this: