I don't have "System.Net.Mail.SmtpPermission" ?

Last post 09-14-2008 2:50 PM by shirkedvs. 5 replies.

Sort Posts:

  • I don't have "System.Net.Mail.SmtpPermission" ?

    05-16-2007, 7:03 AM
    • Member
      point Member
    • mrdanh
    • Member since 05-16-2007, 10:48 AM
    • Posts 3

    My project works well (send e-mail) in local PC, but it can not when uploaded. I have checked SMTP port again and again, port 3535 is open. May the problem caused by config file? I think no. Appreciate all the help, thank you so much and hope to hear from you soon!

     

    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.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    Source Error:

    Line 66:         SmtpClient client = new SmtpClient();
    Line 67:         client.Credentials = new System.Net.NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD);
    Line 68:         client.Port = 3535;   //SMTP_PORT
    Line 69:         client.Host = SMTP_HOST;
    Line 70:         client.EnableSsl = ENABLE_SSL;


    Source File: d:\hosting\clearpathadmin\contact-us.aspx.cs    Line: 68

    Stack Trace:

    [SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
       System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
       System.Security.CodeAccessPermission.Demand() +59
       System.Net.Mail.SmtpClient.set_Port(Int32 value) +106
       stats_contact_us.SendMail() in d:\hosting\clearpathadmin\contact-us.aspx.cs:68
       stats_contact_us.btnSubmit_Click(Object sender, EventArgs e) in d:\hosting\clearpathadmin\contact-us.aspx.cs:48
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
       System.Web.UI.Page.ProcessRequest() +86
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
       System.Web.UI.Page.ProcessRequest(HttpContext context) +49
       ASP.contact_us_aspx.ProcessRequest(HttpContext context) in App_Web_zel1nich.0.cs:0
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
    

    Filed under:
  • Re: I don't have "System.Net.Mail.SmtpPermission" ?

    05-18-2007, 4:13 AM

    Hi

     "Request for the permission of type 'System.Net.Mail.SmtpPermission" means you should have had unrestricted permissions, please check the security level for your websites and sets it to a unrestricted set of permissions.  To fix it, added this line to Web.Config for the web site:

     <trust level="Full" originUrl="" />

    Best Regards
    XiaoYong Dai
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: I don't have "System.Net.Mail.SmtpPermission" ?

    05-18-2007, 4:45 AM
    • Member
      point Member
    • mrdanh
    • Member since 05-16-2007, 10:48 AM
    • Posts 3

    Hi Xiao Yong Dai

    Thank you so much,  SMTPPermission may only need "Medium" trust level. But whatever, this error occured! Contact with hosting company, thay told me to modify my web.config but I don't know howSad. Can u or anyone help me? THANK U SO MUCH!

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: This configuration section cannot be used at this path.  This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.

    Source Error:

    Line 20: 
    Line 21: 
    Line 22: 			<trust level="Full" originUrl="" />
    Line 23: 
    Line 24: 		<customErrors mode="Off"/>

  • Re: I don't have "System.Net.Mail.SmtpPermission" ?

    05-18-2007, 4:46 AM
    Answer
    • Member
      point Member
    • mrdanh
    • Member since 05-16-2007, 10:48 AM
    • Posts 3

    Hi Xiao Yong Dai

    Thank you so much,  SMTPPermission may only need "Medium" trust level. But whatever, this error occured! Contact with hosting company, thay told me to modify my web.config but I don't know howSad. Can u or anyone help me? THANK U SO MUCH!

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: This configuration section cannot be used at this path.  This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.

    Source Error:

    Line 20: 
    Line 21: 
    Line 22: 			<trust level="Full" originUrl="" />
    Line 23: 
    Line 24: 		<customErrors mode="Off"/>

  • Re: I don't have "System.Net.Mail.SmtpPermission" ?

    05-20-2007, 11:36 PM
    Answer

    Hi mrdanh

    Yes you're correct. In ASP.NET version 2.0, SmtpPermission is available at full, high, and medium trust levels. 

    I'm afraid the hosting company used a custom trust (SMTPPermission is denied) and prevented you from override the trust level.

    So, You'd better contact your ISP for this problem.

    Best Regards
    XiaoYong Dai
    Microsoft Online Community Support

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: I don't have "System.Net.Mail.SmtpPermission" ?

    09-14-2008, 2:50 PM
    • Member
      10 point Member
    • shirkedvs
    • Member since 08-28-2008, 3:01 PM
    • Posts 5

    Please send me

Page 1 of 1 (6 items)