Problem Sending Email Attachment from .NET 2.0 ASPX Page
Here is the full text of the exception:
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.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
Line 57: if (txtAttachment.Text.Length > 0)
Line 58: {
Line 59: attachment = new Attachment(txtAttachment.Text, MediaTypeNames.Application.Octet);
Line 60:
Line 61: // Add time stamp information for the file.
Source File: e:\inetpub\clients\daar-ul-ehsaan.org\DataEntry\SendEmail.Aspx.cs Line: 59
Stack Trace:
[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Obj ect demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +58
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) +644
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +66
System.Net.Mail.AttachmentBase.SetContentFromFile( String fileName, String mediaType) +76
System.Net.Mail.AttachmentBase..ctor(String fileName, String mediaType) +36
System.Net.Mail.Attachment..ctor(String fileName, String mediaType) +20
SendEmail.Button1_Click(Object sender, EventArgs e) in e:\inetpub\clients\daar-ul-ehsaan.org\DataEntry\SendEmail.Aspx.cs:59
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.dataentry_sendemail_aspx.ProcessRequest(HttpCo ntext context) in App_Web_sendemail.aspx.c182f6a3.nbjcknuq.0.cs:0
System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +75
Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3618
How and where do I change the security?
The file in question is located at www.daar-ul-ehsaan.org\dataentry\The Biggest.pdf
Thanks in advance
Isa Paine
What do I do?