Overriding the meaning of ~ in ASP.NET

Published on 05 April, 2007 at 17:35

Random techie discovery... You can override the meaning of the tilde (~) in paths in ASP.NET.

I often use the ~ so that it doesn't matter whether my web application is sitting at the root level or in a virtual directory. For example, I could include this as the href of a link tag to make ASP.NET write out the correct path of a stylesheet:

~/App_Assets/Css/Screen.css

I discovered today that you can override the meaning of that ~, to potentially point anywhere you like, such as a subfolder. See here for details.

0 Comments Add your own

Add a New Comment

 


 

Comment Guidelines: Basic XHTML is allowed (a href, strong, em, code). Line breaks and paragraphs are automatically generated. Off-topic or inappropriate comments will be edited or deleted. Email addresses will never be published. Thanks.