MVC3中的安全例外

时间:2013-08-01 14:56:22

标签: asp.net-mvc-3 security code-access-security asp.net-mvc-3-areas

您在我的会员申请中实现“向会员发送电子邮件”功能时遇到以下问题。我做了一些研究并添加了

             <system.web>
             <securityPolicy>
                <trustLevel name="Full" policyFile="internal"/>
             </securityPolicy>
            </system.web> 

到我的Web.config,然后再次部署到服务器,但问题仍然存在。有任何想法吗?提前谢谢。

   Server Error in '/TestApp' Application.

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

   Source Error: 

   An unhandled exception was generated during the execution of the current web request. Information  regarding the origin and location of the exception can be identified using the exception stack trace below.

1 个答案:

答案 0 :(得分:1)

发送电子邮件时,您可能正在指定可能不允许的SMTP端口号。

这是我正在谈论的一个例子: SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission'