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 3493956
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:56:52+00:00 2026-05-18T11:56:52+00:00

In almost every ASP.NET MVC example I’ve come across, I always see Url.Content being

  • 0

In almost every ASP.NET MVC example I’ve come across, I always see Url.Content being used to reference CSS, JavaScript, and Images. Not once has anyone explained WHY to use it.

Anyone care to explain?

What’s so bad about doing:

<img src="/Content/Img/MyImage.png" alt="My Image" />
<script src="/Scripts/jquery.js" type="text/javascript"></script>
<link href="/Content/Css/Default.css" rel="stylesheet" type="text/css" media="all" />
  • 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-18T11:56:53+00:00Added an answer on May 18, 2026 at 11:56 am

    What you have works the same as Url.Content(). Url.Content() is just like adding a ~ to be beginning of your paths:

    <script src="~/Scripts/jquery.js" type="text/javascript"></script>
    

    Just ensures the path is always correct with routing. You can also make a Html helper method to make this easier:

    public static string RenderScript(this HtmlHelper htmlHelper, string file) {
                var f = file.EndsWith(".js") ? file : string.Concat(file, ".js");
                return string.Format("<script src=\"/public/scripts/{0}\" type=\"text/javascript\"></script>", f);
            }
    

    Then you can just put this in your masterpage:

    <%=Html.RenderScript("jquery")%>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In almost every page in my ASP.NET MVC site I am using information about
In almost every Sinatra example I've seen, despite what it does, it always has
I see IoC and DI mentioned pretty much everywhere for ASP.NET MVC. While I'm
When I develop an ASP.Net webapp, it almost always requires some kind of authentication
Almost every new Java-web-project is using a modern MVC-framework such as Struts or Spring
I used Term::ShellUI and almost every thing is working as expected but the issue
A login page on our asp.net website uses https – while almost all of
I'm trying to get setup using the DataAnnotations validator in ASP.Net MVC 2.0 Beta,
I've been spending the past several weeks working on my asp.net mvc site following
We are developing an ASP.NET MVC web app that will be hosted on Windows

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.