Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 04, 2013 04:40 PM by Ruchira
Member
406 Points
519 Posts
Jan 02, 2013 03:01 PM|LINK
Hi;
I am trying to debug a web application through an IIS web site on my local machine.
I am copying contents from an xml file to another on my local c:\ drive.
And this works fine when I use the ASP.net built in web server but now that I have created my project as an IIS 5.1 web site and
am stepping through its code in debug mode I don't have access rights to this file any more.
His is obviously an IIS safety feature but how to I grant premission and to which account do I grant this permission to ?
Thanks for your insights !
Participant
1441 Points
319 Posts
Jan 02, 2013 03:15 PM|LINK
see this article http://support.microsoft.com/kb/271071
Jan 02, 2013 04:07 PM|LINK
Thanks for your answer.
I am not sure where to begin with the article.
Here is the line of code which I want to execute from within my asp.net code behind StreamWriter wr = new StreamWriter(@"c:/capture.xml");
Here is the error :
System.UnauthorizedAccessException was unhandled by user code Message=Access to the path 'c:\capture.xml' is denied. Source=mscorlib StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) at System.IO.StreamWriter.CreateFile(String path, Boolean append) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) at System.IO.StreamWriter..ctor(String path)
Who doesn't have access ? The web site the asp.net ? IIS security data ?
1380 Points
287 Posts
Jan 02, 2013 08:02 PM|LINK
Check this link...
http://www.codeproject.com/Questions/161874/Problem-accessing-folder-on-file-server-from-web-s
207 Points
82 Posts
Jan 04, 2013 11:05 AM|LINK
Hello,
Try to copy xml into a file which is inside your website domain or web project folder. By default asp.net won't allow you to save or move file outside the domain .
All-Star
42940 Points
7024 Posts
MVP
Jan 04, 2013 04:40 PM|LINK
You should give permission to IUSR. My blogpost will help you with that.
http://ruchirac.blogspot.com/2012/08/how-to-grant-folder-permissions-to-iusr.html
Please 'Mark as Answer' if this post helps you.
GMann
Member
406 Points
519 Posts
Why can't I write to an XML file on my local drive from my web application ?
Jan 02, 2013 03:01 PM|LINK
Hi;
I am trying to debug a web application through an IIS web site on my local machine.
I am copying contents from an xml file to another on my local c:\ drive.
And this works fine when I use the ASP.net built in web server but now that I have created my project as an IIS 5.1 web site and
am stepping through its code in debug mode I don't have access rights to this file any more.
His is obviously an IIS safety feature but how to I grant premission and to which account do I grant this permission to ?
Thanks for your insights !
Dr. Acula
Participant
1441 Points
319 Posts
Re: Why can't I write to an XML file on my local drive from my web application ?
Jan 02, 2013 03:15 PM|LINK
see this article http://support.microsoft.com/kb/271071
GMann
Member
406 Points
519 Posts
Re: Why can't I write to an XML file on my local drive from my web application ?
Jan 02, 2013 04:07 PM|LINK
Thanks for your answer.
I am not sure where to begin with the article.
Here is the line of code which I want to execute from within my asp.net code behind StreamWriter wr = new StreamWriter(@"c:/capture.xml");
Here is the error :
System.UnauthorizedAccessException was unhandled by user code
Message=Access to the path 'c:\capture.xml' is denied.
Source=mscorlib
StackTrace:
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamWriter.CreateFile(String path, Boolean append)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path)
Who doesn't have access ? The web site the asp.net ? IIS security data ?
Madhu1234
Participant
1380 Points
287 Posts
Re: Why can't I write to an XML file on my local drive from my web application ?
Jan 02, 2013 08:02 PM|LINK
Check this link...
http://www.codeproject.com/Questions/161874/Problem-accessing-folder-on-file-server-from-web-s
mani2009it
Member
207 Points
82 Posts
Re: Why can't I write to an XML file on my local drive from my web application ?
Jan 04, 2013 11:05 AM|LINK
Hello,
Try to copy xml into a file which is inside your website domain or web project folder. By default asp.net won't allow you to save or move file outside the domain .
Ruchira
All-Star
42940 Points
7024 Posts
MVP
Re: Why can't I write to an XML file on my local drive from my web application ?
Jan 04, 2013 04:40 PM|LINK
Hello,
You should give permission to IUSR. My blogpost will help you with that.
http://ruchirac.blogspot.com/2012/08/how-to-grant-folder-permissions-to-iusr.html
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.