Top VPS Hosting Provider

Welcome to the myhosting.com Forums.
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2011
    Posts
    1

    Default 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?

  2. #2
    suwunk is offline Super Moderator
    Join Date
    Aug 2010
    Posts
    1,080

    Default

    Hi Isa Paine,

    Hope this solution helps;
    adding this to the web.config under system.web : <trust level="Full" />
    "System.Security.SecurityException: Security error" error message when the virtual directory points to a remote share in ASP.NET

    Cheers
    Last edited by suwunk; 2011-01-13 at 05:37 AM.


 

Similar Threads

  1. .net 4
    By kfrancis in forum Virtual Server
    Replies: 1
    Last Post: 2010-09-21, 03:52 AM
  2. Replies: 2
    Last Post: 2010-05-21, 04:24 PM
  3. Replies: 0
    Last Post: 2010-03-02, 01:46 PM
  4. Replies: 1
    Last Post: 2009-10-20, 09:28 AM
  5. Published Page not what I published - asp.net master page
    By jimbaum in forum Troubleshooting
    Replies: 1
    Last Post: 2008-09-10, 11:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts