Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 489247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:47:21+00:00 2026-05-13T01:47:21+00:00

First we have the form: <link href=../../../content/somecontent /> This is annoying to figure out

  • 0

First we have the form:

<link href="../../../content/somecontent" />

This is annoying to figure out (need to count path depth one by one) and the most prone to mistakes. Someone came up with this:

<link runat="server" href="~/content/somecontent" />

This is easier but I don’t know how casual I can be using that solution. Can it be used anywhere? Does it work with Spark? How does it affect rendering speed? And the last and worst resort would be:

<link href="/content/somecontent" />

This doesn’t allow the web app to reside in a sub directory which I don’t like, especially for testing purposes. Are there other, better ways that I’m not aware of?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:47:21+00:00Added an answer on May 13, 2026 at 1:47 am

    You can use

    <link href="<%= Url.Content("~/Content/somecontent") %>" />
    

    to point to some file. Using relative locations (your first example) won’t work all the time because of the way routing can change depending on the current URL. In most of my projects, I use URL helpers to do this kind of thing.

    public static class ExtensionsOfUrlHelper
    {
        // TODO: Prepare for .NET 4.0, this will return MvcHtmlString
        public static string Asset(this UrlHelper url, string asset)
        {
            var path = "~/assets/" + asset;
            return string.Format("<link href=\"{0}\" />", url.Content(path));
        }
    }
    

    This keeps the view lighter, and I can just type…

    <%= Url.Asset("some_asset") %>
    

    … and be done with it.

    When .NET 4.0 comes out, and you update your code base, you’ll change your static to return a shiny new MvcHtmlString. This will happily prevent and double-escaping. (And you’ll want to do this in any code that writes out HTML.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this form: <input type=checkbox value=First />First <input type=checkbox value=Second />Second <input type=checkbox
I have a simple form with 2 pull-down menus. What I can't figure out
I have form build with yii framework. The first 2 inputs is first_name and
I have a form with 3 fields (simplyfied example). The first one is a
Let's say I have a form that collects a first name and a last
in my application i have an form where user enter their username first .
I have 2 forms set up. In the first form I have the following
I am using MVC3, EF Model first. I have a form with two DropDownList
I have a MOSS workflow where on the first form, the user can choose
Currently I have two pages: The first page contains an input form, and the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.