views:

248

answers:

1

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.

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.

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.

I've done a couple searches and found out the IIS trust levels is most likely causing the problem.

If this IIS change my hosting company made is a permanent fix to this windows secrity issue is there any way around this? Since I am on a shared server I don't really have access to IIS. Can I use a different method other then WebRequest.Create to get data from an outside server? Or can I do something with permissions/trust levels in my application code?

Thanks in advance!

A: 

Add the following to your web.config (under system.web):

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

Here's more information on the trust element.

Keltex
I've tried that before and I get a "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." when I try to access my webpage
hanesjw
I think your hosting company is trying to block these these types of requests.
Keltex
you are right, they were blocking it. Thanks for the response
hanesjw