asp.net site mobile phone support

我是研究僧i 提交于 2020-01-13 20:23:17

问题


I need to make my site work well on a blackberry, i haven't put too much effort into getting this working yet, but i have a few questions which google is struggling with.

I've read about detecting brower type and modifying the default behaviour of asp.net controls here

How would I go about supplying a differant stylesheet to a specific browser, should i just do this?

if (Request.Browser.Browser.ToString() == "blackberry") //pseudocode
{
    Response.Write("bb.css");
}
else
{
    Response.Write("bb.css");
}

This will work fine, but i feel like there is a better method, i'm sure i've read about something in the past but i can't seem to recall.

I'm also considering a response.redirect to a differant page for a blackberry, which at the moment i would implemenet in a similar way.

Any thought or suggestions.


回答1:


Check this out

http://mdbf.codeplex.com/

Also nerddinner.com at http://nerddinner.codeplex.com/




回答2:


Generally it is possible for a browser to pretend it's a different one (this was used e.g. by Opera which was by default set up to pretend it's an IE to overcome some restrictions on problematic sites). Personally I think the blackberry and similar devices are quite easy to detect so there's no reason to not do it like in your sample.. the site from Vivek looks good as well ;)




回答3:


While not directly related to your actual question, you may want to read what I wrote as an answer here under the title "Identifying the phone".

What you should really be looking for is a way to detect a feature of the current device and boy are you in for a lot of work if you want to do it properly. The problem as I stated in that other answer is that thanks to the history of user agent strings they haven't been reliable for a long time.

If mobile phones as a whole won't be your primary platform, you shouldn't dwell into this that much, find something that works such as checking if user agent string contains "Blackberry" and be satisfied with that. If, however, you really do want to do it properly, you have to develop a feature detection framework to do the job with all its possible combinations and permutations for you - there's no easy path when going down that road.

I'm sorry that I feel the need to be such a demotivator.



来源:https://stackoverflow.com/questions/2078324/asp-net-site-mobile-phone-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!