Need a View to create a relative URL

Posted on 2011-10-20
Last Modified: 2012-05-12
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.

Question by:newbieweb
    LVL 22

    Assisted Solution

    Is there any specific reason of not using href attribute of anchor tag?

    Accepted Solution

    I was curius how to get a relative URL into an href.  The answer to my question was to use the following:


    for the href:

    <a href='@Url.Content("~/Home/Page2/")' title="See Page 2">Page2</a>

    Author Closing Comment


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now