Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
When I run my project on the local machine it works fine but when I uploaded my website on plesk ,it gives me an error like this:

Access to the path 'C:\inetpub\vhosts\hamshahrisalam.com\httpdocs\Web.sitemap' is denied


My code is

System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory +"Web.sitemap", string);


What can I do?
Please help me.
Posted
Updated 7-Sep-10 23:07pm
v2
Comments
Dalek Dave 8-Sep-10 5:07am    
Edited for Readability and Grammar.

In this case, Server.MapPath() is not the main issue. As I can see, your code is trying to write to a Web.sitemap file and in order to complete this operation successfully, the Asp.net worker process must have write permission to that specific file (The user account under which the Asp.net process runs).

In your PC, the worker process user account might have write permission on the specific file, so, it's working. But, on server, the worker process might not have the necessary permission. So, it is failing there.

To solve this issue, you have two ways to follow:

1. Make sure that the worker process user account has necessary write permission on the target folder/file.

2. Or, override your Asp.net application to run under a different user account who has write permission on that specific folder/file (This is called Impersonation and usually done by setting an element in web.config. You can google to learn how to do this.

Hopefully, you will be able to solve your problem.
 
Share this answer
 
v2
Comments
faezeh66 9-Sep-10 0:55am    
thank you a lot for your help,
faezeh66 9-Sep-10 3:15am    
it does not work for me
I believe you are using a shared hosting server. Usually the shared hosting servers doesn't provide IO access to files and directories....If you really require then you need to ask the hosting provider for the access.

It will be better if you can post you r objective (why do you want to write to the sitemap file...etc) so that an alternative way can be found :)
 
Share this answer
 
Comments
faezeh66 9-Sep-10 3:12am    
should be Exclusive hosting server?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900