7

I have a wcf web service deployed in IIS 7. When an error occurs I need to log the message that caused the error. The log needs to be created on a network share where developers have access to the share (as we do not have access to the server where the service is deployed). A virtual directory was created in IIS whose physical path is on the network share.

How can I get the physical path of the virtual directory? I have tried using

System.Web.Hosting.HostingEnvironment.MapPath(virtualDirectoryPath) 

but this just returns the physical path on the server where the service is located.

For example, if the virtual directory is "WSLogs" and I give the virtualDirectoryPath as "~/WSLogs" I will get back C:\inetpub\wwwroot\myServiceDirectory\WSLogs\

2
  • Just to make sure I understand, you are looking to get the network path of the virtual directory and NOT the physical path on the server? Commented Sep 3, 2013 at 21:16
  • In IIS the virtual directory has it physical path set to the physical path on the network (the share folder). I want to get that share folder path. Commented Sep 3, 2013 at 21:23

1 Answer 1

13

The virtual directory was created at the same level (under Default Web Site node) as the web service. After moving the virtual directory to be located under the web service node itself, I was able to get the physical path for the virtual directory using:

System.Web.Hosting.HostingEnvironment.MapPath(virtualDirectoryPath) 

where the virtualDirectoryPath is ~/WSLogs

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.