Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access to the path...is denied. When trying to load XML File

Posted on 2009-07-02
4
Medium Priority
?
955 Views
Last Modified: 2012-05-07
URL : http://www.absolutedivorce.com/new/

Hi guys,

I am getting the followinf error when executing the code in the snippet:

Error : System.UnauthorizedAccessException: Access to the path 'D:\WWWRoot\absolutedivorce.com\www\new' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

Line 24:         m_document = new XmlDocument();
Line 25:         m_document.Load(schema);
Line 26:     }
 
This only occurs on my hosted space, it works fine locally tested. They claim that the IUSR user account has permission to read the folder in question and i have checked that the 2.0 framework is the target framework for this directory in the web folder.
 
Any suggesions?
 
Thanks
 
Apresto

Open in new window

0
Comment
Question by:apresto
  • 2
4 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 24761620
Have u tried using <identity impersonate="false" /> in the web.config file
0
 
LVL 23

Author Comment

by:apresto
ID: 24761777
Hi, thanks for the reply. Yes i put that in the web.config file in the sub directory where these files are and i got the same error. I put it here:
<authentication mode="Windows"/>
<identity impersonate="false" />

any other idea?
0
 
LVL 3

Accepted Solution

by:
sandip-mishra earned 2000 total points
ID: 24769795
hi....

i think you are assigning the "file name" to "schema"......

use it as follows

schema = server.MapPath("FIleLocation");

but before doing it you must have the file in the specified location.

Regards

Sandip Mishra
0
 
LVL 23

Author Comment

by:apresto
ID: 24923036
That is spot on, i was referencing a file that didnt exist in my Server.Mappath, i didnt realise i hadnt uploaded it to the server, what a big headache for such a small mistake :)
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question