views:

37

answers:

1

I currently have an ASP.NET MVC application that exists. I want to add a small mobile friendly section to the site. I want to keep it extremely simple and integrate http://mdbf.codeplex.com/ into my project. Then on Home/Index check if the are mobile, then forward them on to the Mobile Controller (http://mysite.com/mobile/index).

However, I also want to setup if they type http://m.mysite.com it will automatically display mobile/index without having the URL be (http://m.mysite.com/moble/index. Also, let's say I had another action method in the mobile controller. I would want to be able to do http://m.mysite.com/MobileList instead of having to do http://m.mysite.com/Mobile/MobileList

Any thoughts on how to get this done? Would I need to mess with routes? Currently I am just using the default controller/action/id route that comes by default. Again, I am trying to keep this as simple as possible.

+4  A: 

Do you really require a separate controller? We do something much like in this post. We use the same controller but different views, and a custom ViewEngine to select. Easy, works, and no separate URI needed.

Craig Stuntz
+1. I agree with Craig. If you want to keep things simple keep the same controllers for mobile and desktop version and let the (customized) ViewEngine to serve different views based on useragent and/or requested domain.
PanJanek
The problem I have with this is there is no way to always guarantee mobile. What I've seen is guys to http://mobile.site.com which will force them into mobile mode (my thought would be to direct them to the mobile controller) right?
aherrick
If you want to *force* mobile, you add that feature *after* you get auto-detect working. We do it with a cookie. In practice, it's used only for testing; auto-detect always works for other cases. Your needs may be different.
Craig Stuntz
and you should check http://code.msdn.microsoft.com/WebAppToolkitMobile
fravelgue