Joe Grant
Joe Grant

Reputation: 3

Use Anchor Link in asp.net MVC

I put an html anchor link in one of my Views. Just like this:

<a href="SomePage.html"> Some Link<a>

It does not go to the page. I suppose it is because it does not have a Controller and is not wired up with MapRoute.

My question is: Can I use a regular html anchor tab in an MVC application or Must I wire it up with the MVC Controller and MapRoute?

Upvotes: 0

Views: 772

Answers (2)

Rohan Singh
Rohan Singh

Reputation: 21455

This is because an HTML file in a view folder doesn't automatically have an action associated with it. Remember, with MVC, views are just something that is rendered by a controller that is serving a route. The views folder is just a handy place to store these views, and doesn't map to any actual URL's unless there is a route specified.

The general convention is to put these kinds of files in the Static or Content folder, where they will be served up just fine.

Upvotes: 2

Daniel A. White
Daniel A. White

Reputation: 190907

You should be able to. Is the path correct? What page is it on? Are you going up the path tree?

Upvotes: 0

Related Questions