473,812 Members | 2,914 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

~ 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 1336
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\wwwr oot\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.co m> wrote in message
news:fa******** **********@news-binary.blueyond er.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.Resolve Url

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

--
Thanks.

Lostinet (MS ASP.NET MVP)
lo*********@hot mail.com
---------------------------
Need MessageBox,Comb oBox,DatePicker ,PasswordBox,Tr eeView,ASP.Net RPC ?
http://www.lostinet.com/
"suzy" <su**@spam.co m> дÈëÏûÏ¢
news:fa******** **********@news-binary.blueyond er.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*****@aboutf ortunate.com> wrote in message
news:10******** *****@corp.supe rnews.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\wwwr oot\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.co m> wrote in message
news:fa******** **********@news-binary.blueyond er.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.co m> wrote in message news:fa******** **********@news-binary.blueyond er.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*****@aboutf ortunate.com> wrote in message
news:10******** *****@corp.supe rnews.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*****@aboutf ortunate.com> wrote in message
news:10******** *****@corp.supe rnews.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\wwwr oot\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.co m> wrote in message
news:fa******** **********@news-binary.blueyond er.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:HyperLin k 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
10179
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 accidentally entered are properly represented when the document is served. My programming language allows me to get the ascii value for any individual character so what I am doing when a change is saved is to look at each character in the content and...
4
17885
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 problem is the charset? How I can avoid this warning? But the worst thing isn't the warning, but that the program doesn't work! The program execute all other operations well, but it don't print the converted letters: for example, in the string...
7
96340
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 %% should be used. Wouldn't it have been better (from design perspective) if the same escape character had been used in this case too. Forgive me for posting without verfying things with any standard compiler, i don't have the means for now.
18
4639
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 has some different characters in it that I am trying to remove. The small a with two dots over it and the small y with two dots over it. Here is my code so far to remove the small y: Private Sub Button2_Click(ByVal sender As System.Object, ByVal...
9
8268
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
11014
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 the initialization of the wchar_t string is illegal. here is my function: #include <stdio.h> #include <stdlib.h> #include <wchar.h> #include <wctype.h> #include <string.h>
17
10713
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 talking with another team -- codepage -- at the same time. I am more confused when I saw sometimes we need codepage parameter for wide character conversion, and sometimes we do not need for conversion. Here are two examples,
3
10205
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. This is not a regular expression tutorial. Assumes you are already familiar with basic regular expression concepts and terminology. If not, you may want to read some regular expression tutorial. See the end of the article for links to online resources....
7
2581
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 third party ecommerce service for hosting its online store. A few months ago this third party commerce site began using PGP file encryption on XML files (e.g. web orders) transferred to us as part of the ongoing PCI security compliance.
10
3983
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 instance, one of the characters has an ASCII code of 150 (it looks like a dash '-'), when I'm debugging this character is displayed as the square box that Windows uses for unsupported characters and when it's copied to the database it's stored as...
0
9607
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10664
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10417
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9219
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7677
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.