views:

29

answers:

2

Hi All,

I have a requirement to capture the HTTP User Agent header coming in from a device, take the value and remove a 'uuid' This UUID can then be used to direct the device to the correct location to give it the files relevant to the device.

In webforms I was able to get it using

Request.ServerVariables["HTTP_USER_AGENT"]; //inside of Page_Load method

How would I go about this in MVC? I'm still learning MVC2 so please bear with me :-)

Thanks in advance,

Aaron

+1  A: 

You do it the same way, in the controller:

Request.ServerVariables.Get("HTTP_USER_AGENT");

The Request object is part of ASP.NET, MVC or not.

See this for example.

Oded
Works a treat that Oded cheers!
Aaron
A: 

It should be in the Request.Headers dictionary.

NickLarsen