acadia
acadia

Reputation: 2621

"Access Denied" error in Visual Studio.Net 2010

I have converted an ASP.NET application that was developed in VS.NET 2003 to VS.NET 2010. After fixing all the build errors and running it, it works well except in one place where I am opening a document that I just copied into a specific folder from the ASP.NET page.

I get an "Access Denied" error when I try to open the file from the ASP.NETpage. But when I go to Windows Explorer and try to view the file I dont have any problem. How might I resolve this?

Here is the code:

string url;
sring newurl;

url = GetDocumentPath(540450); 
if (url != null)
{   
     newurl = @"c:\" + System.IO.Path.GetFileName(url);
     System.IO.File.Copy(url, newurl, true);
}  
Process.Start("iexplore", newurl);

Upvotes: 1

Views: 2776

Answers (3)

WEFX
WEFX

Reputation: 8572

You may have to consult this page on Microsoft's site. It offers a few workarounds for these Visual Studio "Access Denied" errors.

Upvotes: 0

wullinkm
wullinkm

Reputation: 140

Indeed sounds like the user doesn't have the correct permisions, however it could also be caused by the path in newurl being a directory.

Besides it seems that your application stores files in C:\ which depending on your operating isn't accessible for users without administrator permissions (windows vista/server 2008 and up), you could try to use process monitor to find out if the correct permissions are used. See this blog post:

http://improve.dk/archive/2009/10/21/solving-access-denied-errors-using-process-monitor.aspx

Upvotes: 1

tutts
tutts

Reputation: 2433

Sounds like ASP.net user account is not getting permissions to the folder. You need to right click the folder with the files in explorer, go to permissions and then search for the ASP user (something like ASPNET), add full folder permissions and it should work.

Upvotes: 0

Related Questions