1and1 windows hosting with asp.net [closed]

喜你入骨 提交于 2019-12-06 14:18:18

问题


Not sure if anyone has used 1and1 MS Hosting and encountered problems with their trust levels?

I am simply trying to send mail using system.net.mail in asp.net (which works fine) but when its online with 1and1 I get this error:

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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I asked 1and1 and they sent me a machine.config file with their settings but no explanation with what to do with it.

Sorry I can't put up with there useless tech support any more.

Anyone got any ideas what I should do with the machine.config or something?


回答1:


And the answer is........

1and1 do not allow access to system.net.mail. But do however allow access the obsolete system.web.mail (oh joy)

basic instructions with available mail server here




回答2:


Is it possible that your host's smtp server requries some type of authentication to relay the mail? That is all I can think of. When you instantiate the SmtpClient, try setting the credentials, I'm not certain what credentials you would supply, perhaps something from your hosting provider?




回答3:


You could also try modifying your web.config and changing the trust level in there. I've had similar issues in the past with a couple of other hosts, and this worked for me:

<system.web>
    <trust Level="Full" />
</system.web>



回答4:


Almost any shared hosting (you only have access to a FTP site) is going to be medium trust. Its a common limitation. You have to develop against a medium trust server in order to weed out those issues. Sometimes they're easy to deal with, sometimes not.

An alternative is to do virtual hosting. You get a virtual server that you can administer yourself. That way you can run your websites under full trust. I do that with my 1and1 website. While people bitch about them (what host doesn't have people bitching about it?) they have the cheapest virtual servers out there, last time I checked.



来源:https://stackoverflow.com/questions/1915032/1and1-windows-hosting-with-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!