Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have developed a client winform app in C# .net 2.0. The application is a clickonce app that installs via the web. The users can get to the installation website without a problem.

Once installed the users are reporting that the application is throwing an error. When a look at the problem log on the user's pc, I see that the app is receiving a 407 proxy error whenever it tries to use a webservice (that resides on the same server as the clickonce installation files.)

I originally assumed that if a user could reach the installation URL via their browser, an app on their laptop could reach a webservice on that same server... maybe this is a bad asumption? Any ideas?
Posted

When accessing a web service, if the user is behind a proxy (say a corporate proxy used by a company to route all internet traffic) then you need to cofigure the service to use the proxy

This would be along the lines of
WebService service = new WebService();
IWebProxy proxy = HttpWebRequest.DefaultWebProxy; 
proxy.Credentials = CredentialCache.DefaultCredentials;
service.Proxy = proxy;


This tells the web service to use the default proxy and credentials configured for internet access.
 
Share this answer
 
Dylan, thanks for the reply. Unfortunately I just tried this and it did not work. still getting a 407 proxy error. Just to make sure I am explaining accurately:

The user connects to the intranet via their office (which is behind the firewall) and they are accessing a website that is also behind the firewall (they are not prompted for a password when they go to the site.) When the user clicks the link to go to the clickonce install page, they have no problem getting to the site. The installation seems to occur without fail... the problem arises when the app starts-up it calls the web service and throws the 407 error. The webservice is on the same server as the clickonce; so I don't know why a user can access the url to install but can't access the web service on the same domain...
 
Share this answer
 
Comments
Dylan Morley 7-Dec-10 10:55am    
The reason is because they are accessing your click once setup from their web browser which has already specified network credentials \ proxy servers etc. This is all negotiated for you when navigating to the site, it's part of the browsers functionality.

When accessing a web service programatically, it's *not* all handled for you. You have to specifiy any proxy server settings or credentials.

This is why the users can access the site with the installer, but your code in the application is failing.


Just to confirm, you've made code changes to specificy the proxy credentials, redeployed the code to the user with the changes & they still see the error?
atlquaker 7-Dec-10 12:01pm    
Dylan,
Ok, that explanation makes sense.

Yes: I did make the changes, reposted to the clickonce location, and verified that the user successfully installed the new version (-the app is set-up to check for new versions upon startup.)
atlquaker 7-Dec-10 12:07pm    
And here is my code, just so you see exactly what I am doing:

try
{
myWebService.DoStuff ws = new myWebService.DoStuff();
IWebProxy proxy = HttpWebRequest.DefaultWebProxy;
proxy.Credentials = CredentialCache.DefaultCredentials;
ws.Proxy = proxy;
}
catch (Exception ex)
{
//log error
AppFunctions.Errors err = new AppFunctions.Errors();
err.logError(ex.Message.ToString());
}
WheatleyJJ 10-Feb-17 4:19am    
You probably won't need this, as its 7 years on..

You're setting your proxy settings after making the network call. You want to create the proxy settings and assign them before calling DoStuff();

Like so:
try
{
myWebService ws = new myWebService;
IWebProxy proxy = HttpWebRequest.DefaultWebProxy;
proxy.Credentials = CredentialCache.DefaultCredentials;
ws.Proxy = proxy;
DoStuff res = ws.DoStuff();
}
catch (Exception ex)
{
//log error
AppFunctions.Errors err = new AppFunctions.Errors();
err.logError(ex.Message.ToString());
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900