November 15th, 2013
ASP.net : Tilde (~) sign
"~" (Tilde) is a special character that is usually used to set
URL paths for
Asp.net Server controls and this character instructs the Asp.net run time to resolve the relative path of the server control.
Few days back one of my office colleague was getting following error, when he tried to access a webpage in the asp.net application. This application was hosted on his machine on IIS web server.
Parser Error Message: The File ‘/MyApp/Inventory/MasterPages/MasterPage.Master’ does not exist.
<%@ Page Language=”vb” AutoEventWireup=”false” CodeBehind=”[File Name]” Inherits=”——–”
After looking at the issue, we identified that at runtime the “~” was resolved to current directory instead of web application’s root folder “/MyApp/”.
We looked at the code and the physical path of virtual directory, both looks correct.
Then we looked at the “Inventory” folder. This folder was set as an “application” instead of a “virtual directory”. We converted it back to virtual folder and that resolved the issue!
How to convert “Application” back to virtual folder:
– Right click the “Application” in IIS
– Click on “Delete”
– It will not remove the application or files, it will convert it back to virtual folder.