473,386 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

~ character

i have seen examples where the ~ character is used in the web.config file
when storing directories.

eg: ~/files/data.xml

what does that character mean?

Nov 18 '05 #1
6 944
The tilde character represents the root of the web site. It automatically
starts you at the base folder.

So for example, if your folder structure was: c:\inetpub\wwwroot\mysite

And inside of the site you had the folders:
pages
images

Normally if you were in the pages folder and needed to access an image you
would have to use "..":
<img src="../images/myimage.gif">

Of course if you had another folder inside of pages and you were in a file
there you'd need two sets of "..":
<img src="../../images/myimage.gif">

But using the tilde you automatically start at the root directory and don't
need to know how far back in the directory structure any folder is:
<img src="~/images/myimage.gif">

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"suzy" <su**@spam.com> wrote in message
news:fa******************@news-binary.blueyonder.co.uk...
i have seen examples where the ~ character is used in the web.config file
when storing directories.

eg: ~/files/data.xml

what does that character mean?

Nov 18 '05 #2
~/ means ApplicationRoot when you use Control.ResolveUrl

(e.g. Image control use ResolveUrl to translate the url)

--
Thanks.

Lostinet (MS ASP.NET MVP)
lo*********@hotmail.com
---------------------------
Need MessageBox,ComboBox,DatePicker,PasswordBox,TreeVie w,ASP.Net RPC ?
http://www.lostinet.com/
"suzy" <su**@spam.com> дÈëÏûÏ¢
news:fa******************@news-binary.blueyonder.co.uk...
i have seen examples where the ~ character is used in the web.config file
when storing directories.

eg: ~/files/data.xml

what does that character mean?

Nov 18 '05 #3
After I posted I realized that my example is a little misleading. I
shouldn't have used an image tag as the example.

The tilde character is translated by .net server side as starting in the
root directory. If you use the tilde in client side code a web browser won't
know what it means.

The example I gave is good for how the structure works but using a tilde
client side in the example I gave would of course produce a broken link.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:10*************@corp.supernews.com...
The tilde character represents the root of the web site. It automatically
starts you at the base folder.

So for example, if your folder structure was: c:\inetpub\wwwroot\mysite

And inside of the site you had the folders:
pages
images

Normally if you were in the pages folder and needed to access an image you
would have to use "..":
<img src="../images/myimage.gif">

Of course if you had another folder inside of pages and you were in a file
there you'd need two sets of "..":
<img src="../../images/myimage.gif">

But using the tilde you automatically start at the root directory and don't need to know how far back in the directory structure any folder is:
<img src="~/images/myimage.gif">

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"suzy" <su**@spam.com> wrote in message
news:fa******************@news-binary.blueyonder.co.uk...
i have seen examples where the ~ character is used in the web.config file when storing directories.

eg: ~/files/data.xml

what does that character mean?


Nov 18 '05 #4
Here is some more information if you are interested

http://www.dotnetdashboard.com/Deskt...dex=0&tabid=64

"suzy" <su**@spam.com> wrote in message news:fa******************@news-binary.blueyonder.co.uk...
i have seen examples where the ~ character is used in the web.config file
when storing directories.

eg: ~/files/data.xml

what does that character mean?


Nov 18 '05 #5
Hi,

I know about mapping to the root directory , but you don't need the tilda to
do that.

you can just use:

/files/data.xml

instead of:
~/files/data.xml

so I was just wondering what the tilda actually did.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:10*************@corp.supernews.com...
After I posted I realized that my example is a little misleading. I
shouldn't have used an image tag as the example.

The tilde character is translated by .net server side as starting in the
root directory. If you use the tilde in client side code a web browser won't know what it means.

The example I gave is good for how the structure works but using a tilde
client side in the example I gave would of course produce a broken link.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:10*************@corp.supernews.com...
The tilde character represents the root of the web site. It automatically
starts you at the base folder.

So for example, if your folder structure was: c:\inetpub\wwwroot\mysite

And inside of the site you had the folders:
pages
images

Normally if you were in the pages folder and needed to access an image you would have to use "..":
<img src="../images/myimage.gif">

Of course if you had another folder inside of pages and you were in a file there you'd need two sets of "..":
<img src="../../images/myimage.gif">

But using the tilde you automatically start at the root directory and

don't
need to know how far back in the directory structure any folder is:
<img src="~/images/myimage.gif">

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"suzy" <su**@spam.com> wrote in message
news:fa******************@news-binary.blueyonder.co.uk...
i have seen examples where the ~ character is used in the web.config

file when storing directories.

eg: ~/files/data.xml

what does that character mean?



Nov 18 '05 #6

Hello suzy,
so I was just wondering what the tilda actually did.


Think of the ~ as an alias for the virtual root.

So, for example, you have a web application that is accessible via:

http://localhost/virtRoot1/Test.aspx

and in test.aspx, you have

<asp:HyperLink NavigateUrl="~/Test2.aspx"/>

the ~ would translate into /virtRoot1

I hope this clears things up...

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: chandy | last post by:
Hi, I have an Html document that declares that it uses the utf-8 character set. As this document is editable via a web interface I need to make sure than high-ascii characters that may be...
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
18
by: james | last post by:
Hi, I am loading a CSV file ( Comma Seperated Value) into a Richtext box. I have a routine that splits the data up when it hits the "," and then copies the results into a listbox. The data also...
9
by: simchajoy2000 | last post by:
Hi, I know what the ASCII Character Codes are for the 2nd and 3rd powers in VB.NET but I can't find the 6th power anywhere - does anyone know what it might be or if it even exists? Joy
15
by: wizardyhnr | last post by:
i want to try ANSI C99's unicode fuctions. so i write a test program. the function is simple, but i cannot compile it with dev c++ 4.9.9.2 under windows xp sp2, since the compiler always think that...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
3
KevinADC
by: KevinADC | last post by:
Purpose The purpose of this article is to discuss the difference between characters inside a character class and outside a character class and some special characters inside a character class....
7
by: tempest | last post by:
Hi all. This is a rather long posting but I have some questions concerning the usage of character entities in XML documents and PCI security compliance. The company I work for is using a...
10
by: Paul W | last post by:
Hi all, I have an application that reads data in from a text file and stores it in a database. My problem is that there are some characters in the file that aren't being handled properly. For...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.