I am using the following method of detecting a device and displaying a specific view based on it within my Global.asax.cs file
protected void InitializeBundles()
{
var PhoneScripts = new ScriptBundle("~/bundles/MobileJS")
.Include("~/Scripts/jquery.mobile-1.*",
"~/Scripts/jquery-1.*");
var PhoneStyles = new StyleBundle("~/bundles/MobileCSS")
.Include("~/Content/jquery.mobile-1.4.5.min.css",
"~/Content/jquery.mobile.structure-1.4.5.min.css",
"~/Content/jquery.mobile.theme-1.4.5.min.css");
BundleTable.Bundles.IgnoreList.Clear();
BundleTable.Bundles.Add(PhoneScripts);
BundleTable.Bundles.Add(PhoneStyles);
}
protected void InitializeDisplayModeProviders()
{
var phone = new DefaultDisplayMode("Phone")
{
ContextCondition = ctx => ctx.GetOverriddenUserAgent() != null && ctx.GetOverriddenUserAgent().Contains("Android")
};
var phone2 = new DefaultDisplayMode("Phone")
{
ContextCondition = ctx => ctx.GetOverriddenUserAgent() != null && ctx.GetOverriddenUserAgent().Contains("iPhone")
};
var Tablet = new DefaultDisplayMode("Phone")
{
ContextCondition = ctx => ctx.GetOverriddenUserAgent() != null && ctx.GetOverriddenUserAgent().Contains("iPad")
};
DisplayModeProvider.Instance.Modes.Insert(0, phone);
DisplayModeProvider.Instance.Modes.Insert(1, phone2);
DisplayModeProvider.Instance.Modes.Insert(2, Tablet);
}
}
This inserts a string that points to a mobile specific view.
It works perfectly, except when I use the Forms Authentication method in the Account controller for my solution.
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
{
return RedirectToLocal(returnUrl);
}
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
This function disregards the Mobile Specific view and automatically directs me to the View that is specific for desktop browsers. in the "RedirectToLocal(returnUrl);" command.
Instead of returning me to /Home/Index.Phone.cshtml
It returns me to /Home/Index.cshtml
It appears that the device detection functionality used in the Global.asax.cs file doesn't support the Redirect from the controller.
Any Ideas how to get this to work.