maya90 — 2011-12-08T15:35:31-05:00 — #1
I don't understand why getting userAgent seems so complicated in .NET..
in JSP you can get userAgent with just one line of 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/library/system.net.httpwebrequest.useragent.aspx (need in C#)
from above url:
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#???
matt_daly — 2011-12-08T15:58:22-05:00 — #2
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.
maya90 — 2011-12-08T16:00:46-05:00 — #3
I'm not using MVC..
wwb_99 — 2011-12-08T16:25:56-05:00 — #4
It is the same for webforms.
Example you saw is for setting the user agent when making a http request.