473,804 Members | 3,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTTPWebResponse : Winform = Pass; ASP DLL = Fail

Hello,

I am having an issue with an object (deployed as VB.Net dll w/ Interop)
instanciated from an ASP page. The object is created just fine but fails when
attempting to make an HTTPWebRequest to another companies HTTP server. This
same object works just fine from a Windows Form. The error I keep getting
from the ASP hosted version of the object is as follows:

"Exception in configuration section
handler(c:\wind ows\microsoft.n et\framework\v1 .1.4322\Config\ machine.config
line 74)"

The "line 74" area of my machine.config deals with the proxy configuration.

The confusing part, for me, is that my internet connection does not make
use of a proxy server. In Internet Explorer I do not have any proxy settings
enabled. Also, why would I be able to reach an outside server under a
WinForms application but not from an ASP page using the same dll? Thank you
for any ideas or suggestions.

- DWek

Nov 18 '05 #1
4 1758
a winform app runs under your user profile, where you have setup the intenet
connection settings with IE. an asp.net page runs under a service account
with no profile, so no internet settings exist, so the ones in machine
config are used. these need to be setup correctly for your enviroment.

-- bruce (sqlwork.com)
"DWrek" <dw***@nospam.n ospam> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
| Hello,
|
| I am having an issue with an object (deployed as VB.Net dll w/ Interop)
| instanciated from an ASP page. The object is created just fine but fails
when
| attempting to make an HTTPWebRequest to another companies HTTP server.
This
| same object works just fine from a Windows Form. The error I keep getting
| from the ASP hosted version of the object is as follows:
|
| "Exception in configuration section
| handler(c:\wind ows\microsoft.n et\framework\v1 .1.4322\Config\ machine.config
| line 74)"
|
| The "line 74" area of my machine.config deals with the proxy
configuration.
|
| The confusing part, for me, is that my internet connection does not make
| use of a proxy server. In Internet Explorer I do not have any proxy
settings
| enabled. Also, why would I be able to reach an outside server under a
| WinForms application but not from an ASP page using the same dll? Thank
you
| for any ideas or suggestions.
|
| - DWek
|
Nov 18 '05 #2
Hi DWrek,

I think Bruce's suggestion is reasonable. Since the ASP(OR ASP.NET) are
running under the the certaihn service's service account which is different
from the winform app(use the logon user account). Have you also tried the
same code in an asp.net web application? I think the problem is also likely
to occur. You can have a try and also check to see whether there is any
internal or external proxy we need to specify.
If there is any new findings, please feel free to post here.
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.)

Nov 18 '05 #3
Thank you both for your suggestions. I believe you are right on target. I was
able to resolve the issue by editing the machine.config file on my system.

After taking a closer look at the exception I was getting I found there to
be an "Inner Exception" within the original exception. Looking at this inner
exception I found there was an error trying to access the registry. What I
think was happening was this:

1) In the machine.config the key <proxy usesystemdefaul t="true"> was set to
true.
2) Because of this the ASP.NET page was trying to access the registry to
determine what my default proxy settings were (derived from Internet
Explorer).
3) It was here that the exception was thrown because the "ASPNET" account
did not have permissions to access the registry and hence, the exception I
was seeing.

So I solved the problem by setting the attribute of the <proxy> key to
"usesystemdefau lt=false". Now though this solves the problem it does make it
necessary to alter the machine.config file on every web server that I deploy
this solution on. I would like to avoid this so I am looking for a way to
bypass the proxy directly from the .NET dll. Any suggestions?
"Steven Cheng[MSFT]" wrote:
Hi DWrek,

I think Bruce's suggestion is reasonable. Since the ASP(OR ASP.NET) are
running under the the certaihn service's service account which is different
from the winform app(use the logon user account). Have you also tried the
same code in an asp.net web application? I think the problem is also likely
to occur. You can have a try and also check to see whether there is any
internal or external proxy we need to specify.
If there is any new findings, please feel free to post here.
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.)

Nov 18 '05 #4
Hi DWrek,

Thanks for your response. I did some further research on this and here are
the findings:
When you are using <proxy usesystemdefaul t="true"/> (which is the default
in
machine.config file), then it will try to access the IE settings. These
settings
are stored in the HKCU hive of the registry. This hive is per user and is
loaded
only when somebody is logged on to the machine. Setting this to default
makes sense
only when you are writing client interactive applications (like Windows
Forms
application). In which case the settings will be same as IE settings for
that user
(the user would have logged onto the machine where the code is run). There
is
another caveat to this : This will not apply for "Use automatic
configuration
script" setting as documented in the <proxy> section in the config file.
You need
to explicitly specify the proxy server in IE options.
In your scenrio you are doing this from a web application which is non
interactive
user (nobody logged on).

For web applications, it seems that we should always
use the following workarounds:
1)Use the Proxy class in the code and specify it in Webrequest class as
follows.
This will result in not taking the settings from config files.
public string MakeQuerywithpr oxy()
{
WebProxy proxyObject;
proxyObject = new WebProxy("<repl ace with proxy in SF>", 80);
WebRequest request = WebRequest.Crea te("<replace with some external web
address>");
request.Proxy = proxyObject;
WebResponse response = request.GetResp onse();
TextReader reader = new StreamReader(re sponse.GetRespo nseStream());
String content = reader.ReadToEn d();
reader.Close();
return content;
}
2)Specify proxy that you want a web application to use in the web.config
file:
<defaultProxy >
<proxy
usesystemdefaul t = "false"
proxyaddress = "http://proxyserver:80"
bypassonlocal = "true"
/>
<defaultProxy/>
This should override the machine.config file contents.

However, as for your senario, since you're calling the assembly in classic
ASP page which didn't have a web.config (if use app.config , we may need to
provide a config for the DllHost.exe such as DllHost.exe.con fig which may
have no difference from changing machine.config) and you also mentioned
that the exception occur just at you creating the WebRequest( have no
chance to set the Proxy ,yes?). I feel abit strange at this, I've done a
simple test on my side expose a .net class as below:

=============== =============== =
[ClassInterface( ClassInterfaceT ype.AutoDual)]
public class WebRequestUtil
{
public string GetWebPageConte nt(string url)
{
string html = string.Empty;

WebRequest wq = HttpWebRequest. Create(url);
wq.Proxy = new WebProxy(wq.Pro xy.GetProxy(new Uri(url)));

WebResponse wp = wq.GetResponse( );
StreamReader sr = new
StreamReader(wp .GetResponseStr eam(),System.Te xt.Encoding.UTF 8);

html = sr.ReadToEnd();

return html;
}
}
=============== =============== ====

as COM interop and call it in classic asp. I configure the asp app's
vritual dir as allow anonymous and use the IUser_Machine account (only in
the Users group). But the code works well. So I'm wondering whether there
is any enviromental specific issue? Would you have a test on some other
machines to see whether they can make httpwebrequest call correctly( just
request a certain external site like google.com or ...)?

Please feel free to let me know if there is any new findings or problems.
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.)


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1326
by: zbcong | last post by:
hello in my winform,there is a datagrid,i want to fire some actions when the selected index is changed,but i fail to find the SelectedIndexChanged event to the winform datagrid,why? how can i implement such a function with the winform datagrid???\ thank you
1
2329
by: zbcong | last post by:
hello in my winform,there is a datagrid,i want to fire some actions when the selected index is changed,but i fail to find the SelectedIndexChanged event to the winform datagrid,why? how can i implement such a function with the winform datagrid???\ thank you
1
4207
by: Ravi | last post by:
Hi , i am trying to pass the same session Id to all the webrequest, but sometimes the response.cookies returns zero and sometimes one. is this to do something with cookies expire. In this sample code the line Console.WriteLine("cookies1 count : " + firstResponse.Count.ToString()); and Console.WriteLine("second Cookie : " + secondResponse.Cookies.Count.ToString());
3
7380
by: Karsten Grombach | last post by:
Hi, I'm trying the following: - Imitate a Logon using a Post with HttpWebRequest on remote Webserver (asp 3.0 page using https) - On success redirect to the page (encapsuled in an iframe) supplied by the remote Webserver I can successfuly logon but when I redirect to the supplied url, the webserver does not know me anymore an redirects me back to login page.. I
8
2847
by: Sunil Menon | last post by:
Dear All, We are developing applications in ASP.Net...in one of our applications we would like to use a GridControl...we have tried to use a Server-Side Grid control but found the speed to be an issue...also our clients would like to use a lot of client side events like sorting, searching text, save each row on tab out of a row, use the auto correct feature... after intial r&d we feel that using a Grid Control in WinForms would be a...
16
11058
by: Cheung, Jeffrey Jing-Yen | last post by:
I have a windows form application that generates a request, downloads an image, and waits the user to enter in login info. Unfortunately, this image is dynamic and based on session data. I have read documents on the CookieCollection property of HttpWebRequest. Currently, I have the functionality in my code to be able to accept cookies, and return them upon a new HttpWebRequest; however, upon further inspection of the returning...
0
956
by: Aryan | last post by:
Hi, I am new to HttpWebRequest and HttpWebResponse object, so please help me out for this problem. I am having application which is in ASP.NET. This ASP.NET application talks with ASP and then ASP pages generates the output which is later on used by ASP.NET pages. So in this process I have Default.aspx which talks with A.asp and then later A.asp passes data to B.asp and then B.asp process and finally C.asp generates the result which is...
0
1048
by: Aryan | last post by:
Hi, I am new to HttpWebRequest and HttpWebResponse object, so please help me out for this problem. I am having application which is in ASP.NET. This ASP.NET application talks with ASP and then ASP pages generates the output which is later on used by ASP.NET pages. So in this process I have Default.aspx which talks with A.asp and then later A.asp passes data to B.asp and then B.asp process and finally C.asp generates the result which is...
5
6329
by: marshmallowww | last post by:
I have an Access 2000 mde application which uses ADO and pass through queries to communicate with SQL Server 7, 2000 or 2005. Some of my customers, especially those with SQL Server 2005, have had pass-through queries fail due to intermittent connection failures. I can easily restablish a connection for ADO. My problem is with pass-through queries.
0
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.