How does IsMobileDevice work?

前端 未结 7 1333
情话喂你
情话喂你 2020-11-28 11:01

MSDN makes it sound so easy to detect a mobile browser:

if (Request.Browser[\"IsMobileDevice\"] == \"true\" ) 
{
    Response.Redirect(\"MobileDefault.aspx\"         


        
7条回答
  •  孤城傲影
    2020-11-28 11:34

    A number of *.browser files are shipped with .NET:

    C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers
    

    The runtime uses regular expressions from the *.browser files to match against the incoming User-Agent string, and then sets a bunch of properties based on each match it finds (there can be several in the hierarchy).

    If you need in-depth mobile device support, consider installing the MDBF, which adds support for about 400 devices:

    http://mdbf.codeplex.com/

提交回复
热议问题