SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission'

前端 未结 2 741
梦毁少年i
梦毁少年i 2020-12-10 04:06

This is one of those \'works locally, doesn\'t work on the server\' posts.

I have a simple contact form that sends an email. On the server, I get the following excep

相关标签:
2条回答
  • 2020-12-10 04:20

    I had a similar problem I simply added the following code in the Web.config file and it worked for me

    <configuration>
      <system.web>
        .....
        <trust level="Full" originUrl=""/>
      </system.web>
    </configuration>
    

    I was facing this issue on my Shared Hosting Server. The error was coming up while trying to create an object of SMTP client and then assigning it a port number. Increasing trust level worked pretty well for me. I just elaborated details to make sure it helps some one else too. really appreciate the solution ! As I was unable to comment hence just thanked here the original author.

    0 讨论(0)
  • 2020-12-10 04:28

    A low security level doesn't allow you to specify the smtp port. Default is port 25. Although my ISP specifies port 587, I can use port 25 and it works fine.

    0 讨论(0)
提交回复
热议问题