SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: get userAgent

  1. #1
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    815
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    get userAgent

    I don't understand why getting userAgent seems so complicated in .NET..

    in JSP you can get userAgent with just one line of code:

    Code:
    String userAgent = request.getHeader("user-agent");
    in .Net it seems things are a bit more complicated (what a surprise...;-)

    searched for .NET userAgent, this was one of the first results
    http://msdn.microsoft.com/en-us/libr...useragent.aspx (need in C#)

    from above url:
    Code:
    myHttpWebRequest.UserAgent = ".NET Framework Test Client"; // EXCUSE ME????
    sorry don't get this.. is there a simpler way to get userAgent with .NET 3.5/C#???

    thank you..

  2. #2
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Jersey
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're using MVC it's just Request.UserAgent inside your controller action. Not sure about WebForms but it's probably the same/similar.
    Matt Daly

  3. #3
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    815
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm not using MVC..

    thank you..

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,625
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    It is the same for webforms.

    Example you saw is for setting the user agent when making a http request.


Bookmarks

Posting Permissions

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