c# - MVC4 Force Mobile Site for all requests including Desktop -
i have created mvc 4 internet application project both mobile , desktop devices. want display mobile site globally browsers.
i've been trying use code httpcontext.setoverriddenbrowser(browseroverride.mobile)
this, doesn't seem work correctly no matter put it.
currently can switch desktop site mobile site using viewswitcher impractical desktop site isn't yet functional.
public redirectresult switchview(bool mobile, string returnurl) { if (request.browser.ismobiledevice == mobile) httpcontext.clearoverriddenbrowser(); else httpcontext.setoverriddenbrowser(mobile ? browseroverride.mobile : browseroverride.desktop); return redirect(returnurl); }
all of mobile views in viewname.mobile.cshtml format. appreciated, thank-you.
i'm maybe bit late party, had same problem op , didn't tieson's solution. came alternative, worked great me.
add following code projects global.asax.cs:
protected void application_beginrequest() { request.requestcontext.httpcontext.setoverriddenbrowser(browseroverride.mobile); }
this tells asp.net on every request, it's request of mobile browser.
Comments
Post a Comment