Hi Everyone,
I have a .NET dll that uses the HTTPWebRequest class to make an HTTP
connection to an off-site server. This dll works just fine from a Winform but
when I try to use it from an ASP page (via COM Interop) and get a registry
access exception. I know why this happening. The dll makes the request using
the following:
request = CType(WebRequest.Create(url), HttpWebRequest)
When the dll is being instanciated from an ASP page the ASP process attemps
to read the registry in order to obtain the default proxy value set in
Internet Explorer. Unfourtunetly the ASP process does not have the
permissions to do this, hence the exception being thrown.
I can get around this by changing the <proxy "usesystemdefault=true"> node
of the machine.config to "false". This prevents the dll from even looking for
proxy information. However, since the default value in the machine.config is
"true" I would like to find a solution in the code to prevent checking for a
proxy. This way I do not have to alter the machine.config on the web servers
I deploy to.
I have tried using the following to tell the WebRequest that I do not need
to check for a proxy:
request = CType(WebRequest.Create(url), HttpWebRequest)
request.Proxy = GlobalProxySelection.GetEmptyWebProxy()
However, this does not seem to work because the exception is being thrown on
the first line when I attempt to create the WebRequest.
Any suggestions that someone might have would be appreciated. I have been
combing the web via Google to find and answer but to no avail. Thanks again!
- Dwek