开发者

error with Security Exception

I am getting the following error on my page:

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 you开发者_StackOverflow社区r system administrator or change the application's trust level in the configuration file.

The problem is with the following code

SmtpClient mailClient = new SmtpClient("smtp.gmail.com", 587);

What's weird is that when testing it at my localhost, everything works fine, but when I put it on my 1and1 web host it generates the error above. I contacted their support and here's their answer.

We do check the error logs and the operation require a FullTrust environment which currently fall under restriction on .NET Framewor

k

What should I do?


http://www.telerik.com/community/forums/aspnet/general-discussions/description-the-application-attempted-to-perform-an-operation-not-allowed-by-the-security-policy-to-grant-this-application-the-required-permission-ple.aspx

this helps u..


First off, if you want to reproduce this locally, you need to add a trust level of medium to your web.config.

The problem is that your application needs to make an outgoing request to an external mail server to send the mail. Outgoing requests are not allowed in medium trust environments. If you change the parameters to 'localhost', 25 it will probably work, but I am assuming youre using that mail server for a reason. (Maybe it was just for local development?)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜