简体   繁体   English

WebRequest.Create异常

[英]WebRequest.Create Exception

I just recently started having a very severe problem when using 我最近刚开始在使用时遇到一个非常严重的问题

WebRequest.Create(string url)

I am on a shared server, and recently the server company announced that it had to change the trust level in IIS from Full to Medium on all Windows web servers due to some windows security issue. 我在共享服务器上,最近服务器公司宣布由于某些Windows安全问题,必须将所有Windows Web服务器上的IIS中的信任级别从“完全”更改为“中”。

As a result when I try to execute WebRequest.Create(string url) - (I need this to connect to USPS server to get real-time shipping rates) I get the following exception. 结果,当我尝试执行WebRequest.Create(string url)时-(我需要连接到USPS服务器以获得实时运费),我得到了以下异常。

Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

And the stack trace narrows it down to the WebRequest.Create method. 堆栈跟踪将其范围缩小到WebRequest.Create方法。

I've done a couple searches and found out the IIS trust levels is most likely causing the problem. 我进行了几次搜索,发现IIS信任级别最有可能导致此问题。

If this IIS change my hosting company made is a permanent fix to this windows secrity issue is there any way around this? 如果我的托管公司进行的此IIS更改是对该Windows secrity问题的永久修复,是否可以解决此问题? Since I am on a shared server I don't really have access to IIS. 由于我在共享服务器上,因此我实际上没有访问IIS的权限。 Can I use a different method other then WebRequest.Create to get data from an outside server? 除WebRequest.Create之外,是否可以使用其他方法从外部服务器获取数据? Or can I do something with permissions/trust levels in my application code? 或者我可以在应用程序代码中对权限/信任级别做些什么?

Thanks in advance! 提前致谢!

Add the following to your web.config (under system.web): 将以下内容添加到您的web.config中(在system.web下):

<trust level="Medium" originUrl=".*"/>

Here's more information on the trust element . 这是有关trust元素的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM