【问题标题】:asp.net, url rewrite module and web.configasp.net、url 重写模块和 web.config
【发布时间】:2010-09-26 16:01:26
【问题描述】:

我在 IIS7 (Vista) 上使用带有 .NET 3.5 的 ASP.net 以及 Microsoft 的 URL 重写模块。

这意味着,我有一个

<system.webServer>
    <rewrite>...</rewrite>
    ...
</system.webServer>

web.config 中的部分,但我收到警告,在 system.webServer 中不允许元素“重写”。

如何配置我的系统以允许(甚至可能有 Intellisense)在 web.config 的重写部分?

谢谢 克里斯托夫

【问题讨论】:

  • 我可以确认这个问题在VS2010和IIS7.5中仍然存在。
  • 这会导致我的 mvc 项目的构建失败。很糟糕。

标签: asp.net url web-config module rewrite


【解决方案1】:

我能够在 Visual Studio 2010 中完成这项工作。

从 Ruslan 的帖子 here 开始并下载 2.0 IntelliSense 文件。然后,只需按照他之前发布的指示here。我最终所做的只是按照 Ruslan 的指示运行以下命令:

C:\download_directory\rewrite2_intellisense&gt;cscript UpdateSchemaCache.js

正如 Christoph 在评论中指出的那样,如果您使用的是 Visual Studio 2010,请确保在运行上述命令之前将 UpdateSchemaCache.js 中的 VS90COMNTOOLS 替换为 VS100COMNTOOLS

我不需要重新启动 Visual Studio。我只将&lt;rewrite&gt; 部分添加到适用的Web.config 转换文件中,因为将它放在主Web.config 中会破坏本地调试。

【讨论】:

  • 您好乔恩,感谢您的链接。在 vs2010 中运行良好,但请注意,如果您使用 vs2010,您需要在 UpdateSchemaCache.js 中将“VS90COMNTOOLS”更改为“VS100COMNTOOLS”(提示其他用户:-))
  • 嗨乔纳森。关于那个 web.config 转换 - 你的是什么样的?我能看到的唯一方法是添加第二个包含 的 system.webServer 部分。我宁愿不添加第二个 部分。你有更优雅的方式吗?
  • @Jon FreeLand - 我收到此错误(即使我以管理员身份运行 cmd 提示符)无法打开文件 Xml\Schemas\DotNetConfig.xsd。确保脚本在提升的命令提示符下运行。
  • 我也是。VS 2010的Express版本有问题吗?
  • 对不起,我不知道这是否适用于 Express。我正在使用 Ultimate。
【解决方案2】:

我相信您需要像这样在 web.config 中定义模块:

<system.webServer>
    <modules>
        <add name="UrlRewriteModule" type="UrlRewritingNet.Web.UrlRewriteModule, UrlRewritingNet.UrlRewriter" />
    </modules>
</system.webServer>

更新:可以在这里设置 Intellisense:

http://ruslany.net/2009/08/visual-studio-xml-intellisense-for-url-rewrite-1-1/

更新:验证 sectionGroup 是否在 %systemroot%\system32\inetsrv\config\applicationHost.config 中标识:

<sectionGroup name="rewrite">
    <section name="rules" overrideModeDefault="Allow" />
    <section name="globalRules" overrideModeDefault="Deny" allowDefinition="AppHostOnly" />
    <section name="rewriteMaps" overrideModeDefault="Allow" />
</sectionGroup>

【讨论】:

  • 嗨,我实际上有这个(用于重写 2,.0):
    但问题依然存在...
【解决方案3】:

我认为您需要在系统的 web.config 文件中“安装” URL 重写模块。

您需要通过 IIS 7.0 界面在您的应用程序上安装该模块,或者让您的托管公司为您安装。

【讨论】:

  • 不,我通过 Web Platform Installer 2.0 和 IIS.net 的本机安装程序在多个 Mashine(Vista 和 Win7)上多次安装了 Rewrite Module
猜你喜欢
  • 1970-01-01
  • 2014-08-12
  • 2013-04-23
  • 2014-06-13
  • 1970-01-01
  • 2011-05-23
  • 1970-01-01
  • 2023-03-20
  • 1970-01-01
相关资源
最近更新 更多