How to make WebRequest from ASP without accessing registry for pro

G

Guest

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
 
S

Steven Cheng[MSFT]

Hi Dwek,

Thanks for your posting. As for this problem, I've posted my reply in
another former thread of yours:

Subject: Re: HTTPWebResponse: Winform = Pass; ASP DLL = Fail

in this group. I'd appreciate if you have a look there. If there're any
further questions, please feel free to post in either thread. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top