如何在 SharePoint 2013 中禁用移动视图?
SharePoint 2013的新移动功能相对于之前的版本确实有很大的改进。现在它提供了对各种移动设备、地理位置、Office Web Apps 集成、设备通道等的支持。但是,SharePoint 2013 移动视图存在一定的不足,例如它不提供响应式网站、缺少菜单和导航,人员选择器、上传文件等功能不起作用,日历视图太难导航等。
SharePoint 2013 移动示例:
SharePoint 2013 禁用移动重定向
就我而言,我们希望控制移动网站并禁用公共 SharePoint 网站的移动视图,因为它会加载默认移动视图并禁用大部分功能。以下是帮助我在 SharePoint 2013 中关闭移动视图的两种方法。
- 停用移动浏览器查看功能
- 在 SharePoint 2013 中禁用移动重定向行为
方法 1:停用 SharePoint Mobile 功能
在 SharePoint 2013 中,默认情况下为所有网站启用移动浏览器视图功能。此功能负责在移动设备上查看 SharePoint 时呈现不同的用户界面。要在 SharePoint 2013 中停用移动视图,请按照下列步骤操作:
就这样!这会禁用特定 SharePoint 网站上的移动重定向。可是等等!此功能的范围仅限于站点级别。因此,如果您想要关闭 SharePoint 2013 的移动视图,则必须在 Web 应用程序中的每个网站上重复这些步骤!
使用 PowerShell 在 SharePoint 2013 中禁用移动视图
幸运的是,我们有 PowerShell。让我们使用 PowerShell 停用适合移动设备的网站。
Disable-SPFeature -Identity MBrowserRedirect -Url https://yoursite
移动视图的范围是 Web 对象。因此,为了禁用 Web 应用程序中所有站点上的移动视图,这是我的 PowerShell 脚本。
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$WebAppURL = "https://portal.crescent.com"
#In SharePoint 2010: $FeatureName = "MobilityRedirect"
$FeatureName = "MBrowserRedirect"
#Disable Mobile View feature on all sites in the web application
$WebsCollection = Get-SPWebApplication $WebAppURL | Get-SPSite -Limit ALL | Get-SPWeb -Limit ALL
#Itereate through each web
ForEach($Web in $WebsCollection)
{
#Check if feature is already activated
$feature = Get-SPFeature -web $Web.Url | Where-object {$_.DisplayName -eq $FeatureName}
if($feature -ne $null)
{
#Disable the Mobile browser view feature
Disable-SPFeature -identity $FeatureName -URL $Web.URL -Force -Confirm:$false
write-host "Feature deactivated at site: $($Web.Url)"
}
}
方法 2:更改移动浏览器的重定向行为
要禁用移动网站,让我们编辑“compat.browser”文件 - 该文件列出了要重定向的所有浏览器“用户代理”字符串。默认情况下,此文件位于“c:\inetpub\wwwroot\wss\VirtualDirectories\80\App_Browsers\compat.browser”
- 登录到您的 SharePoint Web 前端,打开 IIS 管理器
- 在 IIS 管理器中,右键单击您的 SharePoint 网站,然后选择“浏览”。这将打开 SharePoint Web 应用程序的虚拟目录。
- 打开“App_Browsers”文件夹,然后在记事本(或任何其他文本编辑器)中打开“compat.browser”文件
- 您将在文件中找到多个“浏览器”节点。例如:
<!-- Windows Phone -->
<browser id="WindowsPhone" parentID="IE6to9">
<identification>
<userAgent match="Windows Phone"/>
<userAgent nonMatch="IEMobile"/>
</identification>
<capabilities>
<capability name="isMobileDevice" value="true" />
</capabilities>
</browser>
- 只需将节点“Capability”的“Value”属性从“true”更改为“false”即可。
<capability name="isMobileDevice" value="false" />- 搜索并替换文件中所有出现的该属性。保存并重新启动 IIS!
此方法关闭所有特定移动浏览器的移动重定向。
关闭 Web 应用程序的移动重定向:
虽然上述方法禁用了每个设备的移动重定向,但某些设备/浏览器可能不会在那里列出。此外,SharePoint 服务包很有可能用最新更新覆盖我们的更改。因此,让我们看看通过编辑 web.config 文件在 SharePoint 2013 中禁用移动视图的替代方法。
在 web.config 文件(位于 SharePoint 网站的根目录下)的
<browserCaps>
<result type="System.Web.Mobile.MobileCapabilities, System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<filter>isMobileDevice=false</filter>
</browserCaps>
和我的截图:
这消除了在 SharePoint 2013 中检测所有移动浏览器的能力。所有这些过程也适用于 SharePoint Foundation。
最佳实践:您可以利用 SharePoint 2013 中的“设备通道”功能,而不是禁用移动视图。设备通道功能允许您使用不同的母版页、页面布局和 CSS 目标来显示相同的网站内容到特定的移动设备。




