Server.MapPath(“.”), Server.MapPath(“~”), Server.MapPath(@””), Server.MapPath(“/”). What is the difference?
Can anyone explain the difference between Server.MapPath(".")
, Server.MapPath("~")
, Server.MapPath(@"")
and Server.MapPath("/")
?
Can anyone explain the difference between Server.MapPath(".")
, Server.MapPath("~")
, Server.MapPath(@"")
and Server.MapPath("/")
?
ASP.NET offers two ways to specify paths for style sheets:
If I have managed to locate and verify the existence of a file using Server.MapPath and I now want to send the user directly to that file, what is the fastest way to convert that absolute path back into a relative web path?
Possible Duplicate:
What’s the @ in front of a string for .NET?
How can I get the relative virtual path from the physical path in asp.net?
The reverse method is like below:
In my ASP.NET’s Web Config file I have the following location elements defined:
I have a script file .
I am using dotlesscss for my css and I remember how to use that but what I am forgetting is how to get the root project path so that I can generate the full file path to my .less file to get for the less engine to parse. How do I get the project root path so that I can generate the path for my less files?
I’m trying to get the absolute path of certain files in a C# class. Server.MapPath
works great of course for ASPX and their code-behind pages, but that doesn’t exist in another class file. I tried HostingEnvironment.MapPath()
, but that complains that the relative virtual path isn’t allowed. Any thoughts?
How do I know the the complete virtual path that my application is currently hosted? For example: