Going to a URL with a VB.NET WebBrowser gives a different result than Firefox?
My problem's simple. I'm attempting to load a login page for a site in a VB.NET WebBrowser control.
When I go to the site in Firefox, I see the site like normal.
When I go to the site with my VB.NET WebBrowser control, I get a 401: Unauthorized error.
What could cause the WebBrowser to load something differently than Firefox? Is there any way around this?
Re: Going to a URL with a VB.NET WebBrowser gives a different result than Firefox?
Quote:
Originally Posted by
joyner.cn
My problem's simple. I'm attempting to load a login page for a site in a VB.NET WebBrowser control.
When I go to the site in Firefox, I see the site like normal.
When I go to the site with my VB.NET WebBrowser control, I get a 401: Unauthorized error.
What could cause the WebBrowser to load something differently than Firefox? Is there any way around this?
What is the url you are trying to navigate?
Re: Going to a URL with a VB.NET WebBrowser gives a different result than Firefox?
Maybe the website checks the browser type/agent...
To try this, use the Navigate method with extra parameters, for example:
vb.net Code:
WebBrowser1.Navigate("URL", "TargetFrame", null, "User-Agent: CustomUserAgent\r\n")
Re: Going to a URL with a VB.NET WebBrowser gives a different result than Firefox?
Oh, interesting. That latter solution helped me find the problem, it was just a dumb issue on my part.
Basically, my program checks to see if I'm already logged in by checking to see if my username appears on the homepage. If it doesn't, it logs in; if it does, it goes on to the next page. That 'next page' is where I was getting a 401 error, but the problem was that I wasn't actually logged in -- but on the front page of the site, an article by me was featured, so my username still appeared.
Silly me. Thanks for that tip, that's really useful.