1

So, i'm trying to detect mobile requests in .net 4.

I discovered the Request.Browser.IsMobile and Request.Browser.MobileDeviceModel. This works great on my windows 7 laptop dev environment. Using my iPad: IsMobile=true, and MobileDeviceModel="IPad".

But when I check this on Windows 2008 Server, I'm getting IsMobile=false, and MobileDeviceModel="Unknown".

After digging around for a while, I discovered these properties are fueled by xml files in the .net framework folders: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\Browsers And then, I noticed that my laptop's Browsers\iphone.xml has ipad info, while my server's same folder and same file does not contain ipad info.

<browsers>
    <gateway id="IPhone" parentID="Safari">
      ...
    </gateway>

    <gateway id="IPod" parentID="Safari">
      ...
    </gateway>

    <gateway id="IPad" parentID="Safari">
      <identification>
        <userAgent match="iPad" />
      </identification>

      <capabilities>
        <capability name="isMobileDevice"           value="true" />
        <capability name="mobileDeviceManufacturer" value="Apple" />
        <capability name="mobileDeviceModel"        value="IPad" />
      </capabilities>
    </gateway>
</browsers>

My first though is to copy of my browser files over to the server. But I want to make sure it's safe and right to do so. Why would my laptop have these extra devices but not my server? It's the exact same .net version. And, is copying these files over the only thing I need to do?

4

2 回答 2

3

您确定您的笔记本电脑实际上没有安装 .NET 4.5?它安装在 C:\Windows\Microsoft.NET\Framework\v4.0.30313 中的同一位置,这有点误导。如果您使用的是 VS2012,那么您很可能安装了 .NET 4.5,它可能具有额外的浏览器配置。

无论如何,是的,您应该能够简单地将这个文件移动到您的服务器,或者如果您确定您实际上有不匹配的版本,则将您的服务器升级到 .NET 4.5。

于 2013-04-23T16:20:48.907 回答
0

我们必须在生产服务器上执行此操作,因为我们还没有准备好升级到 .NET 4.5,但是浏览器检测问题导致 ASP.NET 认为 IE 10 和 11 不支持 JavaScript。修复方法是将 .browser 文件从 .NET 4.5 机器复制到生产 Web 服务器并重新编译 .browser 文件。请注意,重新编译不是免费的,因为它会导致 IIS 重置,从而影响任何用户。另请注意,在将其推送到生产环境之前,我们在较低集成环境中尝试过此操作。

于 2014-09-30T22:07:53.527 回答