简体   繁体   中英

Redirecting mobile visitors to a subdomain

I have an Asp.net MVC website and for that I will making a lighter mobile version and install it on http://m.mysite.com subdomain.

Please tell me what code I can use to redirect the mobile visitors and where should it be placed ?

Also, tell me if this is a better approach or there is an alternative which simply uses CSS to scale down the website ?

All you need to do is check the User-Agent header in the request and redirect as required. This is available to you through the HttpWebRequest.UserAgent property. You might also find this Wikipedia article helpful .

I think this is a good post , you can start with http://weblogs.asp.net/shijuvarghese/archive/2011/02/25/mobile-enabled-web-apps-with-asp-net-mvc-3-and-jquery-mobile.aspx

Using css to scale down or mobile is not a good option IMO, because you should also consider sending less html/images for a mobile device to save bandwidth.

Yes there is a better approach - a responsive build means you only have one code base and one set of content for all devices. Redirecting to a mobile area is the old approach, doesn't always cater for new devices and usually means either duplicate code, duplicate content, or both.

This is probably the best introduction to responsive design I have come across

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM