开发者

ASP.NET MVC MOBILE Controller Route to Subdomain

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 h开发者_高级运维aving 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜