ASP.Net代码中的System.Security.Permissions.SecurityPermission

编程入门 行业动态 更新时间:2024-10-19 22:33:23
本文介绍了ASP.Net代码中的System.Security.Permissions.SecurityPermission的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我使用SMTPClient.Send(MailMsg)发送邮件时遇到以下异常: 请求类型为"System.Security.Permissions.SecurityPermission,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089"的权限失败." 我可以从本地系统发送邮件,但是当我从共享服务器上托管的网站发送邮件时,我遇到了以上错误. 甚至我在web.config中都提到了以下几行.

Hi All, I''m getting the below exception when i''m sending mail with the SMTPClient.Send(MailMsg); "Request for the permission of type ''System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'' failed." I''m able to send the mail from local system, but when i''m sending mail from the website which is hosted in the shared server, i''m getting the above error. Even i had mentioned the below lines in web.config.

<location allowOverride="false" path="Default Web Site"> <system.web> <securityPolicy> <trustLevel name="Full" policyFile="internal"/> <trustLevel name="High" policyFile="web_hightrust.config"/> <trustLevel name="Medium" policyFile="web_mediumtrust.config"/> <trustLevel name="Low" policyFile="web_lowtrust.config"/> <trustLevel name="Minimal" policyFile="web_minimaltrust.config"/> </securityPolicy> <trust level="Full" originUrl=""/> </system.web> </location>

有人可以建议,哪里出了错? 预先感谢, Varshini M.

Can any one please suggest, where is the mistake? Thanks in advance, Varshini M.

推荐答案

这是在公共托管服务上吗?共享服务器"提示是这样. 是您引用站点的web.config还是引用服务器的顶级web.config的web.config? 如果是开发环境中的web.config,是否对上传到生产服务器的内容进行了任何调整? 如果顶级web.config不给予完全信任-并且不包含您的网站具有完全信任"的位置条目-并且将allowOverride设置为false-那么网站的web.config中有什么内容是无关紧要的,您将不会完全信任. 在公共共享主机上,您将无权访问顶层web.config(我希望如此)-并且您的网站也将不是您所发布的代码段中指定的默认网站". 我的直觉反应是,如果您遇到SecurityPermission错误,那么就会遇到信任问题.如果能够解决问题,我很乐意使用的虚拟主机将有问题的网站置于完全信任状态. 希望这对您有帮助. Is this on a public hosting service - ''shared server'' suggests it is. Is the web.config you quote the web.config for your site or the server''s top level web.config? If it''s the web.config you have in your development environment, have you made any adjustments to what gets uploaded to your production server? If the top level web.config doesn''t give Full trust - and doesn''t contain a location entry with Full Trust for your web site - and has allowOverride set to false - then whatever is in the web.config for your site is irrelevant and you won''t have full trust. On a public shared host, you won''t have access to the top level web.config (I hope!) - and your site won''t be the "Default Web Site" as specified in the snippet you posted. My gut reaction is that if you have a SecurityPermission error then you have a trust problem. The web host I use happily puts web sites with problems into Full trust if that solves the problem. Hope this helps.

u可以使用CASPOL.exe完全信任您的文件夹.我也遇到了同样的问题,但是由于下面的链接,我解决了我的问题. 我建议您从下面的链接中下载GUI CASPOL COMMAND GENERATOR 并浏览其中的ur文件夹并运行,它将自动为您的文件夹设置完全信任. brandonpotter.wordpress/2010 /01/23/code-access-security-policy-caspol-exe-gui-utility/ [ ^ ] u can use CASPOL.exe to give full trust to your folder.I also got same problem but due to below link i solved my problem. I recommend u to just download GUI CASPOL COMMAND GENERATOR from below link and browse ur folder in it and run,,it will automatically set full trust to your folder. brandonpotter.wordpress/2010/01/23/code-access-security-policy-caspol-exe-gui-utility/[^]

更多推荐

ASP.Net代码中的System.Security.Permissions.SecurityPermission

本文发布于:2023-11-17 07:11:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609261.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   Net   ASP   System   SecurityPermission

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!