• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 316
  • Last Modified:

Need a View to create a relative URL

I would like the current page to have an anchor tag that bring the user to the Home/Index View when clicked.

I think there are various ways to do this in MVC. I do not want clicking the URL to post back to a Controller Action, which I could then navigate to point at the Home/Index.  I would like to handle this on the client side.

Thanks.
0
newbieweb
Asked:
newbieweb
  • 2
2 Solutions
 
MrunalCommented:
Is there any specific reason of not using href attribute of anchor tag?
0
 
newbiewebSr. Software EngineerAuthor Commented:
I was curius how to get a relative URL into an href.  The answer to my question was to use the following:

@Url.Content()

for the href:

<a href='@Url.Content("~/Home/Page2/")' title="See Page 2">Page2</a>
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now