Reputation: 2093
I have an IIS-hosted WCF service and I am trying to use Directory.Exists()
method. If nonexistent network location is passed, this method hangs. I've googled for it and found that it's "kind of ok" due to Directory.Exists()
inner implementation. But I wrote a simple console application which does the same and Directory.Exists()
never hangs, always returns 'false
'. I run the application under my (admin) account and IIS pool is running under 'Network Service'.
Do you have any ideas why? What is the difference between doing the same inside a service or a console application?
Upvotes: 8
Views: 1787
Reputation: 36035
The key here is really about running on Network Service vs. the admin account.
You know the later can acceess the network location, but you are not really sure if the earlier can.
Here is one example of a case where you could be expecting there is access, but it doesn't really work: https://serverfault.com/a/177150
The fact that the machine with the shared drive is not on a domain is where your main problem is
Upvotes: 1
Reputation: 1961
Use the UNC path instead of a mapped network drive, as the mapped drive is specific to your user account. Also, as KMan pointed out, make sure the application pool identity has access to the UNC path destination.
please visit this link:
http://msdn.microsoft.com/en-us/library/ff649309.aspx How to get working path of a wcf application?
thanks.
Upvotes: 1
Reputation: 2132
Are you sure the application is running as Network Service? A local Network Service account won't have access to the network.
Upvotes: 1
Reputation: 911
This might be caused due to user authorization control stuff that is present in Windows (remember when you try to access a folder that you dont have access in Windows? It kind of waits a long time to answer "You can't access,..." or something like that).
Which is the user you are running the application? Your user id (as per what you said you can access that folder running the console application) is able to see that folder.
So, try to run the application as your own user id.
Furthermore, check this link: https://stackoverflow.com/a/21385162/1378854
Upvotes: 2