I am working on a MVC site which are having two separate views for mobile and web. The background work is same. So I want to have same controller for both view.
Following is folder structure for that.
View -> Folder for view.
Customer -> This folder is for web
Index.cshtml -> Customer listing view for web
MobileCustomer-> This folder is for mobile
Index. cshtml -> Customer listing view for mobile.
Now the back ground things are same for both on the UI for both mobile and web are diffrerent. So I want to use same customer controller for that. So in Controller folder of asp.net mvc project. I have customer controller and I want to use that same.
But I want URL for each mobile are different.
localhost/customer/ -> This will load normal view for customer
localhost/mobile/customer -> This will load mobile view for customer
How I can achieve this with asp.net mvc 3 or 4 application?
ScottHa blogged about a custom view engine that you could use to separate your mobile views from your desktop client views and based on the user agent serve the one or the other. The NuGet is spec-compatible with the built-in functionality in ASP.NET MVC 4 so the migration will be easier for you. So if you are using ASP.NET MVC 3 go ahead, download the
MobileViewEnginesNuGet and start playing with it. And if you are using ASp.NET MVC4, well, that’s already built-in for you.