Sunday, April 21, 2013

Server.MapPath variations

Those are working on in web technologies like ASP.Net and ASP are already familiar with server.MapPath method.  It is used to Maps a virtual or relative path to a physical path. Recently I had discussion with my friends what kind of options we have for Server.MapPath and We have discussed lots of things. So I thought it will be a good idea to write a blog post about it. I know this is very basic but sometimes we were not aware about basic things. So following are different kind of options we have with Server.MapPath.
  • Server.MapPath("~") return the root physical path of application.
  • Server.MapPath(“.”) returns the current physical path of a executing file(i.e .aspx file)
  • Server.MapPath(“..”) returns the current physical path of parent directory of executing file.
  • Server.MapPath("/") returns the he physical path to the root of the domain name
It’s very basic so if you try first one. It will load c:\users\lenovo\documents\visual studio 11\Projects\WebApplication1\WebApplication1\

It’s very easy hope you like it. Stay tuned for more.
Share:

0 comments:

Post a Comment

Your feedback is very important to me. Please provide your feedback via putting comments.

Search This Blog
Loading...
About Me
My Photo

Full Stack Developer,Blogger,Microsoft Mvp, Mentor, Life long learner, 10+ Years of Experience for JavaScript, web and Microsoft technologies. ASP.NET MVC,Web Forms,C#,AngularJs,Golang
Mvp profile
Subscribe to my blog

Enter your email address:

Follow us on facebook
Blog Archive
Total Pageviews