Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileIOPermission denied when using WebRequest

Status
Not open for further replies.

jmcpher

Programmer
Jun 4, 2001
84
US
I am creating a C# dll for use on our intranet, so there are some security issues. I have given the web unrestricted File IO permissions. This function works fine:

Code:
[FileIOPermission(SecurityAction.Assert, Unrestricted = true)]
protected void LoadIt (string path)
{
   XmlDocument doc = new XmlDocument();
   doc.Load(path);
}

but some of our XML is dynamically created from ASP pages, and it times out on some of them that take longer. I couldn't find a way to set the TimeOut through the XML load, so I decided to use a WebRequest. This function gets:
Request for the permission of type System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

Code:
[FileIOPermission(SecurityAction.Assert, Unrestricted = true)]
protected void LoadIt (string path)
{
   XmlDocument doc = new XmlDocument();
   WebRequest request = WebRequest.Create(path);
   request.Timeout = 3600000;
   doc.Load(request.GetResponse().GetResponseStream());
}

I just tried giving the web FullTrust, and it worked. This obviously isn't what we want to do, so any suggestions?

"Programming is like sex, one mistake and you have to support it forever."

John

johnmc@mvmills.com
 
The ASP.NET user (the account the IIS workers run under) ships with a greatly restricted set of privledges. I would start there.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
The DLL is not running on the server, it is running on the client. I apparently forgot to add that part.

"Programming is like sex, one mistake and you have to support it forever."

John

johnmc@mvmills.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top