Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:54:00+00:00 2026-06-02T23:54:00+00:00

While looking for a way to change the user agent string for the webBrowser

  • 0

While looking for a way to change the user agent string for the webBrowser control, I found this nifty method:

    [DllImport("urlmon.dll", CharSet = CharSet.Ansi)]
    private static extern int UrlMkSetSessionOption(int dwOption, string pBuffer, int dwBufferLength, int dwReserved);
    const int URLMON_OPTION_USERAGENT = 0x10000001;

    public static void ChangeUserAgent(string Agent)
    {
        UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, Agent, Agent.Length, 0);
    }

Basically, I needed a way to change the user agent until I want to change it again.

The usual:

webBrowser1.Navigate ("http://www.whatsmyuseragent.com", "_self" , null, "User-Agent: Luke's Web Browser");

Only works for one request.

However, I keep reading everywhere that the first method only works once per session. In my case, it works as many times as I want it to. So my guess is that this is related to the instance of Internet Explorer on the computer?

So my questions are:

  • What version does the end user need to have installed on their computer for this method to work as intended? IE. change as much as I want.
  • Since this is related to the Internet Explorer installed on the computer, does changing the user agent in my application effect the browser?
  • If the user has Internet Explorer open, will this method still work?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:54:03+00:00Added an answer on June 2, 2026 at 11:54 pm

    We use the “UrlMkSetSessionOption” function quite a bit. We have a “custom web browser shell” which is really just an IE user control embedded into a full screen WinForms program. We change the user agent to identify to our web server that this is our “custom” browser shell. But to answer your specific questions:

    1. We’ve used this with both IE8 on XP and IE9 on Win7. I think it is version independent, but we always use the latest version.
    2. As far as we can tell, changing this setting only affects IE running in the process that invoked the method. So if a user launches IE from the desktop, the user agent is unchanged. If you restart the program, the user agent is unchanged.
    3. It works with and without standalone IE instances running. The user agent for those standalone instances remain unchanged.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While looking for a way to temporarily save the search results when a user
i looking for a way to preview the text while im typing in a
I am looking for a way to translate mouse movements - while the left
I'm looking for a easy way to post data to webpages while keeping the
I've been looking for a while and want a way to sort a Javascript
I'm looking for the easiest possible way to hide an UpdatePanel while waiting for
I am looking for a way to change the option value from a select
I am looking for a reliable way to get a notification if the user
I've been looking around for a way to change the background image of my
While looking for some answers in a package source code ( colander to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.