将带有browserCaps部分的Web.config迁移到IIS7的错误

When running the "appcmd.exe" tool to migrate an existing Web Application to IIS7, make sure you have a backup of your web.config.

当运行“ appcmd.exe”工具将现有的Web应用程序迁移到IIS7时,请确保您已备份了web.config。

99.999% of the time the changes made are additive, but there is an obscure issue that I bumped into.

99.999%的更改是累加的,但是我碰到了一个晦涩的问题。

Here's some info on the long-ago-deprecated browserCaps section of the web.config:

这是关于web.config早已弃用的browserCaps部分的一些信息:

Using the browserCaps element in the Web.config file to define browsers is deprecated in the .NET Framework 2.0, but it is still supported. The data in this element is merged with the information from the browser definition files (.browser) that is located in the machine-level %SystemRoot%\Microsoft.NET\Framework\version\CONFIG\Browsers folder and any existing application-level App_Browser folders. For more information, see Browser Definition File Schema (browsers Element).

.NET Framework 2.0中已弃用使用Web.config文件中的browserCaps元素定义浏览器,但仍支持该功能。 此元素中的数据与来自浏览器定义文件(.browser)中的信息合并,该文件位于计算机级%SystemRoot%\ Microsoft.NET \ Framework \ version \ CONFIG \ Browsers文件夹和任何现有的应用程序级App_Browser中文件夹。 有关更多信息,请参见浏览器定义文件架构(浏览器元素)

This section was and is used to tell ASP.NET about the capabilities of various browsers, usually mobile ones. The original idea was that it'd be updated a lot by a company called Cyscape but Cyscape has hijacked their own URL and turned it into an upsell for their BrowserHawk product. The community tried to step up, but the workload is huge. There's some good browserCaps sections out there, one from SlingFive a few years back, a valiant attempt to energize the CodeProject community around this issue by Chris Maunder.

本节过去曾经用来告诉ASP.NET各种浏览器(通常是移动浏览器)的功能。 最初的想法是,一家名为Cyscape的公司会对其进行大量更新,但是Cyscape劫持了自己的URL,并将其转变为他们BrowserHawk产品的追加销售。 社区试图加紧努力,但工作量巨大。 那里有一些不错的browserCaps部分,其中一些来自几年前的SlingFiveChris Maunder围绕该问题激发CodeProject社区的英勇尝试

As I said, this section is deprecated but supported. The preferred - and easier - way is to use BROWSER files, which are more portable and can be installed with ASPNET_REGBROWSERS.

就像我说的那样,本节已弃用,但受支持。 首选且更简便的方法是使用BROWSER文件,该文件更可移植并且可以与ASPNET_REGBROWSERS一起安装

Back to the migration bug. The format of the old browerCaps section was funky from an XML perspective:

回到迁移错误。 从XML角度来看,旧的browerCaps部分的格式很时髦:

<configuration> 
   <browserCaps>
      <result type="System.Web.HttpBrowserCapabilities, System.Web"/>
        <use var="HTTP_USER_AGENT"/>
              browser=Unknown
              version=0.0
              majorversion=0
              minorversion=0
              frames=false
              tables=false
              cookies=false
              backgroundsounds=false ...etc...

It's totally valid XML, but it's very uncommon to see "mixed nodes" in XML, with an Element, then some text, then an element. In this example the browser=Unknown and all that is just 'tunnelled' in a text node that most folks writing XML processing code would ignore, or not see coming.

它是完全有效的XML,但很少见到XML中的“混合节点”,其中包含一个Element,然后是一些文本,然后是一个element。 在此示例中, browser = Unknown,并且所有在文本节点中被“隧道化”的所有东西,大多数编写XML处理代码的人都将忽略或看不到。

It appears that the migration portion of this IIS7 tool...

看来此IIS7工具的迁移部分...

%systemroot%\system32\inetsrv\APPCMD.EXE migrate config "Default Web Site/DasBlog2"

...toasts these text nodes so that the resulting file is just flat out missing them. This is a common mistake when processing XML that I'm likely guilty of as well.

...敬酒这些文本节点,以使生成的文件完全丢失它们。 这也是处理XML时的一个常见错误,我也很可能对此感到内gui

The Moral and Workaround - Backup your web.config and add this section back after migrating. Of course, this only applies if you're using this kind of obscure section. In our case, DasBlog uses it for Mobile Support.

道德与变通方法-备份您的web.config并在迁移后添加此部分。 当然,这仅在您使用此类晦涩的部分时适用。 在我们的案例中, DasBlog将其用于移动支持

翻译自: https://www.hanselman.com/blog/bug-migrating-webconfig-with-a-browsercaps-section-to-iis7

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值