Setting trust level in web.config

I can’t send the email via ASP.NET and sent the email to the web hosts for some help, and I was told to change the security settings and the link was sent:

http://forums.asp.net/t/1111145.aspx/1

I read what I said there and tried to set <trust level="Full" originUrl="" /> in web.config, but then I get an error message:

This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.

I have not installed any other web.config file yet.

So, I asked the web hosts again and asked if this is a server setup, but I got the answer:

You'll need to specify a more specific path.

It's nice, but I don't know what that means!

Having made a little more digging, I wonder if I need to create a separate trust file, is this correct?

Can someone point me in the correct order to adjust my level of trust (I understand that "full" is probably also wrong?), Because I really do not understand what I should do!

+6
source share
2 answers

Trust levels are described here: http://msdn.microsoft.com/en-us/library/ie/wyts434y.aspx . In shared hosting, providers block these settings, so you cannot modify your web.config file. If you explicitly asked your provider to fully trust your application, and if they answered “yes?”, Then you spoke with an uneducated person - either by escalating the request or changing the hosts. “Please configure my application with full confidence” should be clear enough. Please note that they may not want to do this once they understand your request.

In addition, I cannot be sure that sending trust requires complete trust. Sending mail includes the ability to communicate with the SMTP server, and usually web hosts only allow access to them, and they block everything else (to prevent spam). You won’t be able to tell them to make an exception for you, but if you ask, “tell me which smtp and port to use to send email from my asp.net application”, they should provide it to you (otherwise, escalation or changing hosts). In fact, you should have asked them to first help you send the mail before you conclude that the level of trust is what prevents it (now I'm sure it does not).

Also, read this please: https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem

+7
source

Try the following:

  public static void ConfirmMail(string emailTo) { try { MailMessage message = new MailMessage(); message.Subject = "Account Registration From 91calls"; message.From = new MailAddress(Convert.ToString(" admin@91calls.com "),"Admin"); message.To.Add(emailTo); message.BodyEncoding = System.Text.Encoding.UTF8; StringBuilder sb = new StringBuilder(); sb.Append("<html>"); sb.Append("<Body>"); sb.Append("<table cellpadding='0' cellspacing='0' width='100%' border='0'>"); sb.Append("<tr><td align='center'><table cellpadding='0' cellspacing='0' width='100%' border='0'>"); // sb.Append("<tr><td align='left'><asp:Image ID='imgLogo' runat='server' ImageUrl='http://supervau.w01.winhost.com/images/logo.png' />"); sb.Append("</td></tr><tr><td>Hi, <br></td></tr><tr><td align='left'>You are successfylly resgistered with 91 calls.<br>"); sb.Append("<br>Thank you for using, : http://www.91calls.com<br /><br>For questions or concerns regarding your account, please visit : http://www.91calls.com"); sb.Append("</td></tr></table></td></tr></table>"); sb.Append("</Body>"); sb.Append("</html>"); message.Body = sb.ToString(); message.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.Send(message); } catch { } } 
-1
source

Source: https://habr.com/ru/post/907258/


All Articles