what i am trying to achieve is simple; Among all the view which i have in my web application, i have only two razor views that i have created a mobile version for them. so i need to redirect the users to these views if they are accessing the application from their mobile devices. i tried the following on the controller level but it did not redirect the users when i run my test on different mobile devices :-
if (Request.Browser.IsMobileDevice) { return View("MobileStudentStartAssessment"); } else { return View("StudentStartAssessment"); }
So is there another approach that i can follow which can detect most of the mobile devices? Thanks
Put your mobile device in your lan and then type http://<ip adresse of the host computer>/<name of the website> into adress bar from browser on your mobile device.
ASP.NET is a request processing engine. It takes an incoming request and passes it through its internal pipeline to an end point where you as a developer can attach code to process that request. This engine is actually completely separated from HTTP or the Web server.
Requests to an ASP.NET MVC-based Web application first pass through the UrlRoutingModule object, which is an HTTP module. This module parses the request and performs route selection. The UrlRoutingModule object selects the first route object that matches the current request.
You can use the Request.Browser.IsMobileDevice
property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With