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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:07:45+00:00 2026-05-14T01:07:45+00:00

I have an ASP.net master page. In this master, I have all my css

  • 0

I have an ASP.net master page. In this master, I have all my css and javascript files defined. I also have a few images and a few buttons and hyperlinks.

All the urls are all declared as relative ie “/scripts/ian.js”

Everything works fine if this site is the root website, but I need it to work in a virtual directory.

My problem is when I place this website in a virtual directory under a root site, all my links are pointing to the root site. so my links point to http://www.root.com/scripts/ian.js but it should be pointing to http://www.root.com/virtualDir/scripts/ian.js

I thought the Base Href tag in the header would help, but so far it does not seem to be helping in anyway. All the links are still pointing to the root website when i hover over them.

What I would like is a single setting either in IIS or the config file that I can set a root url and any image, script or link either on the master page or content page, would point to the right place.

Any suggestions or ideas are welcome.

Thanks

  • 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-14T01:07:45+00:00Added an answer on May 14, 2026 at 1:07 am

    All the urls are all declared as
    relative ie “/scripts/ian.js”

    Those seem to be absolute URL’s that you’re using, rather than relative URL’s, which is probably why the <base /> tag isn’t having the desired effect:

    This attribute specifies an absolute
    URI that acts as the base URI for
    resolving relative URIs.

    — from http://www.w3.org/TR/html401/struct/links.html#h-12.4

    You could try removing the leading ‘/’ from your URL’s to see if that works?

    Failing that, I tend to use ResolveClientUrl to get around issues like this, which you’d use in the same way as others have suggested using ResolveUrl:

    <script type="text/javascript" src="<%= ResolveClientUrl("~/path/to/js") %>"></script>
    ...
    <img src="<%= ResolveClientUrl("~/path/to/img") %>" alt="..." />
    

    Hope this helps.

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

Sidebar

Related Questions

I have this in an ASP.Net Master Page: <script language=javascript type=text/javascript> <asp:ContentPlaceHolder ID=scriptContentHolder runat=server></asp:ContentPlaceHolder>
I have this code in my ASP.NET MVC project master page: <% switch(Request.Browser.Browser) {
The background to this is that we have a ASP.NET master page that reads
I have a web site in asp.net that uses a master page. In this
I have the following code in a ASP.NET master page: <div id=hyperlinkimage><asp:HyperLink ID=SomeHyperLink runat=Server
I have a asp.net mvc site with a master page and it has following
I have an ASP.Net web page, which uses a Master Page template. The page
In VS 2008, I have an ASP.NET content page having one master page. I
I have a hybrid ASP.NET WebForms/MVC project. In my Master Page, I have a
I have a master page in my asp.net MVC project, which has code like

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.