3.59Configuring User-Agent

Created on Aug 17, 2026~4 min read

The User-Agent request header is a characteristic string that allows servers and peer networks to identify the application, operating system, vendor, or version information of the user agent that issued the request. The framework provides the SetUserAgent method to set the User-Agent request header.

cs
HttpRequestBuilder.Get("https://furion.net/logo.png")    .SetUserAgent(UserAgents.Chrome.PC)    // Conveniently set using the UserAgents static class    .SetUserAgent(UserAgents.Chrome.Mobile)    // Set to a mobile User-Agent    .SetUserAgent(UserAgents.GetRandom())   // Randomly get a browser-type User-Agent    .SetUserAgent(UserAgents.GetByBrowser("Safari"))   // Get the User-Agent of a specified browser type    .SetUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36");    // Or set the User-Agent string directly

UserAgents is a static class provided by the framework for conveniently setting the User-Agent identifiers of mainstream browsers, and it contains the following members:

  • Static methods:

    • GetRandom(isMobile): randomly gets a browser's User-Agent.
    • GetByBrowser(browser, isMobile): gets the User-Agent of a specified browser type.
  • Static members:

    • Chrome: Google Chrome browser
      • PC: desktop User-Agent identifier
      • Mobile: mobile User-Agent identifier
    • Firefox: Mozilla Firefox browser
      • PC: desktop User-Agent identifier
      • Mobile: mobile User-Agent identifier
    • Safari: Apple Safari browser
      • PC: desktop User-Agent identifier
      • Mobile: mobile User-Agent identifier
    • Edge: Microsoft Edge browser
      • PC: desktop User-Agent identifier
      • Mobile: mobile User-Agent identifier
    • Opera: Opera browser
      • PC: desktop User-Agent identifier
      • Mobile: mobile User-Agent identifier
    • Generic: generic browser
      • PC: desktop User-Agent identifier
      • Mobile: mobile User-Agent identifier