0

I have a MVC project (.net fw 4.5) with forms authentication configured in web.config. When browsing from desktop devices all is working great; the user is being redirected to Login view. I installed '51Degrees' from 'Nuget' and set up the configuration as stated in their site. Also, I added 3 mobile views in the Home folder named: Index.iphone, Index.android and Index.mobile which I want the user to be redirected to them when browsing from mobile / tablet devices (depend on the device type)

My problem is that the login view is called first when browsing from mobile/tablet devices and after successful login the Index.mobile is always being called. I don't want the login view to load but instead I would like to show the respective view (based on device(s) type) which has a corresponding link to download the app (google play / app store).

Please your help.

I deleted the redirect section in 51Degrees config file. 'Detector' HttpModule exists in my web config (Nuget added this automatically during 51 Degrees installation.) I have a .dat file in my App_Data folder. I have added DefaultDisplayMode options for android, iphone and mobile (as stated in 51Degrees site) in Application_Start in Global.asax file.

What am I missing ?

ekad
  • 14,436
  • 26
  • 44
  • 46
Shpongle
  • 217
  • 7
  • 16

1 Answers1

0

A good example to look at of usage with MVC is on the GitHub repository within the Examples directory. The BaseController's Initialise method uses a Device model to set relevant properties for the device which can then be accessed through the ViewBag. So in your login view you can use something along the lines of

if( ViewBag.Device.PlatformName == "Android" )
{
    return Redirect("/AndroidApp");
}
else if
...
else
{
    return View();
}

Is this the sort of thing you were wanting?

  • Thanks for the response. Currently the logic has changed and the website is not mobile adjusted. I ended up checking for mobile only and redirect the user to the right area. – Shpongle Oct 25 '16 at 12:20