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

  • Home
  • SEARCH
  • 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 7777243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:05:23+00:00 2026-06-01T18:05:23+00:00

As you know, ASP.NET MVC stores view markup in a Views directory, which is

  • 0

As you know, ASP.NET MVC stores view markup in a Views directory, which is hierarchically incompatible with the URL routes that are used in an ASP.NET MVC web application. On the opposite end, in ASP.NET Web Forms (and in ASP.NET MVC, too), URLs can and usually do have nested “directories”, or rather path separators, and this combined with the fact that web applications are often not hosted in the root path of a URL but rather in a sub-directory i.e. “/stuff/here/MyActualApp”, it is necessary to use a script path relative to the root of the application rather than relative to the root of a URL. Meanwhile, however, Visual Studio script intellisense dictates that URLs map relatively to the file being edited.

Further, I’ve run into a lot of problems with using runat=”server” to virtualize the root path to support “~/”, such as the head tag needing to also be runat=”server”, and this introduces all kinds of other constraints.

Finally, one more thing: if the minified flavor of a script like jQuery is referenced in addition to the intellisense-ready flavor, Visual Studio will balk on it. So you almost have to use escaped code to keep VS from balking.

So I’ve been using this syntax, or variations of it, in Visual Studio 2010 since VS 2005 for including script in my ASP.NET view markup to deal with the discrepancies nested folders for ASP.NET MVC view files (which do not line up with actual URLs) as well as the need to use the vsdoc flavor of jQuery instead of the minified version so that I get intellisense working.

<%if (false) { %>
<script src="../../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<% } %>
<%= "<script type=\"text/javascript\"" src=\"" 
  + ResolveUrl("~/Scripts/jquery-1.4.1.min.js") + "\"></script>"%>

Aside from using a CDN URL, is there a better way than this? It’s ugly. I wish Microsoft could have addressed this by now without resorting to ScriptManager tags (which require server-side forms as well as make the markup even more verbose).

Note: My issue is not with the Intellisense support so much as the last line in the code above, having to emit a line rather than just using real markup. However, I also want intellisense support readiness, too.

  • 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-06-01T18:05:25+00:00Added an answer on June 1, 2026 at 6:05 pm

    In ASP.NET MVC 4, Razor has become smart enough to support “~/” detection. Hopefully the VS11 IntelliSense tooling will keep up with this.

    <script src="~/Scripts/Controls.js"></script>
    

    New in ASP.NET MVC4: Razor changes (Alexander Beletsky)

    Meanwhile, the Visual Studio tooling and the jQuery source (since jQuery was used for reference in the question) have both been heavily modified since the question was originally asked. RickAndMSFT’s answer did not apply at that time. At the current time, his answer is correct; however, since this is a moving target it appears that by the end of this year one would just reference the script directly and Razor and revised VS tooling will take care of everything.

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

Sidebar

Related Questions

The default ASP.NET MVC project sets up a Models directory that I don't know
I know that ASP.NET MVC 1.0 is bin-deployable as explained in Phil Haack's article.
I know that the reason that Microsoft came out with ASP.NET MVC was to
We know that behind the scenes, the ASP.NET MVC framework will use reflection to
In ASP.NET MVC there is Model, View and Controller. MODEL represents entities which are
I have written a simple ASP.NET MVC 2 application that stores data and can
I have an ASP.Net MVC intranet site which uses Windows Authentication to know who
I know the difference between ASP.NET webforms and ASP.NET MVC and I've seen quite
I'm jumping into ASP.Net MVC and wanted to know how tough it's been for
I'm using ASP.NET MVC Validation. I want to know in my javascript functions whether

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.