Hello,
First of all, I'm somewhat new to web development, so hopefully this is easily solved.
I've got a page hosted on an external server to which I do not have access to, and right now, I'm simply trying to append some characters to a text file based on user input to a form on that page. I'm having trouble accessing that text file. Here is the code I'm using
string path = Page.TemplateSo urceDirectory + "Updates.tx t";
// Open the file and add the submitted address to it
System.IO.Strea mWriter writer = System.IO.File. AppendText(path );
writer.Write(th is.txtEmail.Tex t);
writer.Write("; ");
writer.Close();
When I run the above code on the server, I get the following error
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security .SecurityExcept ion: Request for the permission of type 'System.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' failed
followed by an source error with no relevant code, and a stack trace. I'm not quite sure how I should be trying to access a file that sits alongside the cs file that's executing the code, but I'm stumped at the moment. Any help would be greatly appreciated.
Thanks.
- Alex
First of all, I'm somewhat new to web development, so hopefully this is easily solved.
I've got a page hosted on an external server to which I do not have access to, and right now, I'm simply trying to append some characters to a text file based on user input to a form on that page. I'm having trouble accessing that text file. Here is the code I'm using
string path = Page.TemplateSo urceDirectory + "Updates.tx t";
// Open the file and add the submitted address to it
System.IO.Strea mWriter writer = System.IO.File. AppendText(path );
writer.Write(th is.txtEmail.Tex t);
writer.Write("; ");
writer.Close();
When I run the above code on the server, I get the following error
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security .SecurityExcept ion: Request for the permission of type 'System.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9' failed
followed by an source error with no relevant code, and a stack trace. I'm not quite sure how I should be trying to access a file that sits alongside the cs file that's executing the code, but I'm stumped at the moment. Any help would be greatly appreciated.
Thanks.
- Alex
Comment