The application attempted to perform an operation not allowed by the security policy hatası

0

Öncelikle herkese selamlar

Asp.net ile hazırladığım bir siteme iletişim formunda doldurulan mesajı mail ile almaya çalışıyorum ama sitemi host ettiğim firma ile bir türlü çözemedim sorunu 

kodlarım doğuru local de çalıştırdığım zaman mail gönderiyor 

Firma bana kendi hazırladığı örnek mail gönderme fornumu yükledi ftp ye sorunsuz çalışıyor. Ama ben aynı kodları alıp kendim çalışmayı derleyip yüklediğim zaman çallışmıyor. 

Firmaya Framework 4.0 kullanıyormuş bende aynı versiyonu kullanıyorum bir türlü olmuyor. Firma kendilerinden kaynaklanan bir sorun olmadığımı söylüyor. 

Ben aynı kodları Framework 3.5 kullanan başka bir sunucuya 3.5 versiyonuna çevirip yüklediğimde sorunsuz olarak çalışıyor. 

Şimdi bendemi var sorun Yoksa host ettiğim firmada mı yardımcı olursanız sevinirim. 

Bu arada hata yı gönder butonuna bastığımda çalışma zamanı hatası olarak alıyorum. 

 

 

Server Error in '/' 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: 


[No relevant source lines] 

Source File: App_Web_coxyxudy.0.cs Line: 0 

Stack Trace: 


[SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] 
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0 
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31 
System.Security.CodeAccessPermission.Demand() +46 
System.net.Mail.SmtpClient.set_Port(Int32 value) +106 
birligim41._default.btnGonder_Click(Object sender, EventArgs e) in default.aspx.cs:28 
System.EventHandler.Invoke(Object sender, EventArgs e) +0 
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628722 
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103 
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) +35 
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704 
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245 
System.Web.UI.Page.ProcessRequest() +72 
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 
System.Web.UI.Page.ProcessRequest(HttpContext context) +58 
ASP.default_aspx.ProcessRequest(HttpContext context) in App_Web_coxyxudy.0.cs:0 
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341 
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69 

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34249

 

gonlumtoksoy gonlumtoksoy (1)
8 yıl önce sordu

    Toplam 2 Cevap


    0

    Sorunun bir kaç farklı sebebi olabilir:

    Web.config sorunu:

    Şunu dener misiniz? Web.config içinde trust level'i Full olarak ayarlayın.

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

    Port sorunu:

    Smtp portu olarak 587 ya da kullandığınız hosting şirketi hangi portu kullanıyorsa onu kullanın.

    SSL sorunu:

    Relay sunucunuz SSL kullanıyor mu? SSL gerektiriyor mu? bunu kontrol edin. SSL gerektirmiyorsa SSL'i devreden çıkartın.

    smtpSunucu.EnableSsl = false;

    Hatalı SMTP / Relay sunucu:

    Bazı hosting firmaları sadece kendi SMTP sunucularının kullanılmasına izin verir. Örneğin Godaddy. Godaddy üzerinden mail göndermek istiyorsanız 

    relay-hosting.secureserver.net

    sunucusunuz kullanmanız gerekir. 

     Kodları ve hosting şirketinizin adını paylaşırsanız daha iyi olur.

    alattin alattin (16999)
    8 yıl önce cevaplandı

      0

      <body>
          <form id="form1" runat="server">
          <div>
          <div class="modal fade" id="contact" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
       
      <div class="modal-content">
      <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h4 class="modal-title" id="H1">Bize Ulaşın !</h4>
      </div>
      <div class="modal-body">
      <label for="txtFormName" class="col-xs-3">Ad ve Soyad:</label>
          <asp:TextBox ID="txtAd" runat="server"></asp:TextBox>
          <br />
      <label for="txtFormMail" class="col-xs-3">Mail Adresi:</label>
          <asp:TextBox ID="txtMail" runat="server"></asp:TextBox>
          <br />
      <label for="txtFormSubject" class="col-xs-3">Konu:</label>
          <asp:TextBox ID="txtKonu" runat="server"></asp:TextBox>
          <br />
      <label for="txtFormMsg" class="col-xs-3">Mesaj:</label>
          <asp:TextBox ID="txtMesaj" runat="server" TextMode="MultiLine"></asp:TextBox>
          <br />
      <asp:Label runat="server" ID="lblFormResult" style="float:right;width:380px;"></asp:Label>
          <asp:Button ID="btnGonder" runat="server" onclick="btnGonder_Click" 
              Text="Gönder" />
      </div>
      </div>
      </div>
      </div>

          </div>
          </form>
      </body>

       

      protected void btnGonder_Click(object sender, EventArgs e)
              {
                  MailMessage ePosta = new MailMessage();
                  ePosta.IsBodyHtml = true;
                  ePosta.From = new MailAddress(txtMail.Text);
                  ePosta.To.Add("info@incipromosyon.com");
                  ePosta.Subject = txtKonu.Text;
                  ePosta.Body = txtMesaj.Text;
                  SmtpClient smtp = new SmtpClient();
                  smtp.Credentials = new NetworkCredential("info@incipromosyon.com", "parola");
                  smtp.Port = 587;
                  smtp.Host = "mail.incipromosyon.com";
                  smtp.Send(ePosta);
                  btnGonder.Text = "E-Posta Başarıyla Gönderildi";
              }

       

       hosting firması     www.ihs.com.tr

      gonlumtoksoy gonlumtoksoy (1)
      8 yıl önce cevaplandı

      üyelik gerektirir

      Cevap yazabilmek için üye girişi yapmalısınız.

      Eğer uzmanim.net üyesiyseniz giriş yapabilirsiniz: üye girişi yap
      uzmanim.net'e üye olmak çok kolaydır: hemen kayıt ol