Results 1 to 4 of 4

Thread: axwebbrowser and custom user agent

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    2

    axwebbrowser and custom user agent

    Hi all,

    I currently have an axwebbrowser component and i am trying to navigate to a website but sending a custom User-Agent in the http headers, Ive tried:

    Code:
    test = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) 
    Gecko/20070725 Firefox/2.0.0.6"
           
            AxWebBrowser1.Navigate("http://blarblar.com", "", "", "", test)
    However this doesnt work, and if i check the web logs, the user agent is just the same.

    Any ideas?

    Thanks

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: axwebbrowser and custom user agent

    How is the webserver supposed to know what all that data in your test variable even is? headers work with a "HeaderName: HeaderValue" type syntax

    So if you want to override the useragent, you need to specify your string is infact a user agent string. This will allow the override to occur, and the browser control should NOT pass its default useragent string.

    Code:
    test = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.6) 
    Gecko/20070725 Firefox/2.0.0.6"
    AxWebBrowser1.Navigate("http://blarblar.com", "", "", "", test)

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    2

    Re: axwebbrowser and custom user agent

    Man im so stupid, I should have know this!! thanks very much pal, that worked great.

    One more thing though, I checked the logs, and when i viewed the index.html of my test page it worked with the custom user agent, however when it fetched 1 of the css pages it used the default user agent. any way round this?

  4. #4
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: axwebbrowser and custom user agent

    Why are you using custom user agent strings? I can understand wanting to differentiate your web browser from others but you're using the IE engine so any site looking for the IE engine may not recognize your browser and display a broken page.

    If you're going to mimic the user string for Firefox (which will probably break many pages that use IE hacks) then maybe you should look into incorporating the Gecko engine in your browser rather than the IE engine.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width