ASP.NET中的电子邮件安全例外

时间:2015-05-15 12:08:13

标签: asp.net

Security ExceptionDescription:应用程序尝试执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系或更改配置文件中应用程序的信任级别。

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 45:         {
Line 46:             smtp.Host = "smtp.gmail.com";
Line 47:             smtp.Port = 587;
Line 48:             smtp.EnableSsl = true;
Line 49:             smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;


Source File: d:\inetpub\vhosts\softsoftware.in\designscentre\asktheexpert.aspx.cs    Line: 47

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() +61
   System.Net.Mail.SmtpClient.set_Port(Int32 value) +106
   asktheexpert.sendbtn_Click(Object sender, EventArgs e) in d:\inetpub\vhosts\softsoftware.in\designscentre\asktheexpert.aspx.cs:47
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
   System.Web.UI.Page.ProcessRequest() +80
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.asktheexpert_aspx.ProcessRequest(HttpContext context) in App_Web_vkk6wpqv.2.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75


Version Information: Microsoft .NET Framework Version:2.0.50727.5485; ASP.NET Version:2.0.50727.5483 

Security ExceptionDescription:应用程序尝试执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系或更改配置文件中应用程序的信任级别。

网站正确地在Localhost中工作。     但在服务器上出错。 请帮我解决这个错误。

0 个答案:

没有答案