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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:07:30+00:00 2026-05-13T08:07:30+00:00

1) With Html elements that don’t have runat = server attribute, absolute and relative

  • 0

1) With Html elements that don’t have runat = “server” attribute, absolute and relative paths are sent to the browser as they are. But with server controls, Asp.Net runtime provides URL rebasing feature, where URLs ( specified by server controls contained inside Master Pages, Themes or User Controls ) relative to Master pages, Themes or User Controls are dynamically modified so that browser can locate referenced resources using URLs relative to the final page sent to the browser.

a) Besides master pages, themes and user controls, are there any other situations where URL rebasing feature is needed?

2) Assuming test.aspx is located in the root of a web application ( WebApp20/test.aspx ), while image file is located at WebApp20/Images/award.gif, then in the final page sent to the browser both of the following URLs will resolve to src=”Images/award.gif”.

test.aspx:

<img id="A" src="Images/award.gif" alt="image" runat="server"  /> 

<br>

<img id="B" src= "~/Images/award.gif" alt="image” runat="server"  /> 

While I understand that “~” is resolved by Asp.Net to the root of current web application and I also see the benefits of using it in certain situations, in the example above control B doesn’t really need it to find an image, and thus B could instead have src=”Images/award.gif”. And yet I’ve seen quite a few code examples where programmers used “~/Images/award.gif” instead of “Images/award.gif”.

a) So is there a particular reason why in the example above we should prefer using “~/Images/award.gif” instead of “Images/award.gif”?

thanx

  • 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-13T08:07:31+00:00Added an answer on May 13, 2026 at 8:07 am

    The tilda (~) is sort of shorthand in this case. Its used to express the root of your application. The tilda is read by the ResolveClientUrl and the ResolveUrl methods and they return the path based on the actual root (you can call these methods directly too – more information in the links below).

    There are a couple of good reasons to use this method:

    REASON 1

    Your application’s root when deployed to one site, might be ‘/’ and on another site, it might be ‘/somefolder/’. Using this method will give you a correct path in both cases.

    REASON 2

    If you include this image tag in a user control or in your master page, then the resulting pages could have multiple paths (therefore, the relative path to the images folder could be different for each page). This will give you a way to get to the images folder wherever you are in your application.

    REASON 3

    During development, things change a lot. You start an application with one set of requirements, and the client changes their mind. You may start an application with one design, and see that you need to change things. In either of these cases, you may have to move pages around (into and out of folders). Using this method allows you to move files without having to rewrite them.

    See: Control.ResolveUrl Method

    See: Control.ResolveClientUrl Method

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

Sidebar

Ask A Question

Stats

  • Questions 382k
  • Answers 382k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your handlers are in the wrong order as they must… May 14, 2026 at 10:37 pm
  • Editorial Team
    Editorial Team added an answer You can use the assignId command to temporarily assign a… May 14, 2026 at 10:37 pm
  • Editorial Team
    Editorial Team added an answer Linq to Sql (unfortunately) is designed to only connect with… May 14, 2026 at 10:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.