mappath

ASP.NET absolute path back to web-relative path

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?...

Classic ASP Server.MapPath() doesn't work as expected in global.asa

In Classic ASP, Server.MapPath() doesn't always work properly in the Application_OnStart event within global.asa. I have an ASP page at "\testfolder\test.asp" within a virtual root, I have an XSLT file at "\xsl\transform.xsl". My virtual root is located in "c:\inetpub\wwwroot\testapp\". I use MapPath within the ASP page to get the full ...

What is the difference between Server.MapPath and HostingEnvironment.MapPath?

Hi, I wanted to ask what if there is any difference between Server.MapPath and HostingEnvironment.MapPath? Does Server.MapPath have any advantages over HostingEnvironment.MapPath? My original problem was mapping file path on a server when context is not present and I cannot pass Server variable from Global.asax to my method. I used Hos...

Can't save file on webserver: System.UnauthorizedAccessException

I can't save a file on my webserver with FileUpload.SaveAs() or with File.WriteAllText(). The folder I save in is CHMOD 666. My code is this: File.WriteAllText(MapPath(".") + "\\Ads\\test.jpg", "test"); This code works perfectly in Dev. server. Best regards, Lasse Espeholt System.UnauthorizedAccessException: Access to the path *' is...

Writing viewing stats to XML file. Possible problems with losing data count?

Hello I have created XML which holds codes for properties and number of page viewings for that code: <?xml version="1.0" encoding="utf-8"?> <data> <nehnutelnost code="BSPO066P">35</nehnutelnost> <nehnutelnost code="PMDM029P">4</nehnutelnost> </data> I think I have found possible weakness with this, today all counters disapea...

How to MapPath in an IIS7 Rewrite Provider?

Hi, I am using the rather excellent IIS7 Rewrite module (V2), and want to create a custom RewriteProvider that rewrites differently depeneding on whether the physical file exists. I have successfully created a provider, as in this tutorial: http://learn.iis.net/page.aspx/804/developing-a-custom-rewrite-provider-for-url-rewrite-module/ ...