I am working on an ASP.Net MVC application that with views that I want to be able to format for desktop browsers as well as mobile browsers. Both formats would use the same Controllers and Actions but require different views.
What's the best way to do this? Do I do a browser detect in the Action and then invoke the appropriate view? Does the view do the browser detect and then render itself accordingly? Is there something in between return View();
and when the view actually is processed that I can override?
Thanks
MVC (model-view-controller) is considered one of the most popular in the mobile web app development.
You can add support for Pages to any ASP.NET Core MVC app by simply adding a Pages folder and adding Razor Pages files to this folder. Razor Pages use the folder structure as a convention for routing requests.
ASP.NET MVC is no longer in active development.
The Model-View-Controller (MVC) architectural pattern separates an application into three main components: the model, the view, and the controller.
ScottHa has this post about targeting multiple devices with ASP.NET MVC addressing that same problem.
I would suggest either in the view or in something between the controller and the view (the ViewEngine...)
I'd go with custom attributes stuffing appropriate views/masterpages around the returned Model. We use this tactic heavily for Ajaxification, shouldn't be difficult to extend the concept to mobile.
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