Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access the Request object from RazorViewEngine?

I have subclassed RazorViewEngine so I can check for Request.Browser.IsMobileDevice and add a special mobile identifier to the view file name for it to grab. However I can't access the Request object. What should I do?

like image 659
MetaGuru Avatar asked Apr 27 '12 14:04

MetaGuru


1 Answers

You can use either the HttpContext.Current.Request or Context.Request. Although understand how that IsMobileDevice works. It uses a browser file which contains a list of known user agents. As soon as a new device is built, that list is outdated, but in some cases may still identify the device to be mobile correctly. The recommended way is to use 51Degrees or to connect to the services it encompasses directly.

like image 133
Yuriy Faktorovich Avatar answered Oct 03 '22 15:10

Yuriy Faktorovich