【问题标题】:How to host ASP.NET Web Pages w/ Razor Under Wordpress?如何在 Wordpress 下使用 Razor 托管 ASP.NET 网页?
【发布时间】:2012-03-09 10:17:54
【问题描述】:

问题 当我尝试使用 cshtml 扩展访问我的 ASP.NET Web Page Razor 页面时,它们工作正常。如果我删除了扩展程序,WordPress 会尝试查找该 URL,就像它是一篇博客文章一样,我无法通过 Razor 访问该页面或使用“漂亮”的 URL。

我正在使用 Winhost 托管。我的根应用程序目录中安装了 WordPress。该目录包含以下 Web.cofig 文件:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <defaultDocument>
      <files>
        <add value="index.php"/>
      </files>
    </defaultDocument>
    <rewrite>
      <rules>
                <rule name="wordpress" patternSyntax="Wildcard">
                    <match url="*"/>
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
                        </conditions>
                    <action type="Rewrite" url="index.php"/>
                </rule>
        </rules>
    </rewrite>
  </system.webServer>
</configuration>

我的应用程序位于子文件夹“/app”中。您可以前往此处自行测试问题:

http://www.cutrategamer.com/app/game-deals-chart.cshtml

那就去这里试试吧:

http://www.cutrategamer.com/app/game-deals-chart/

在我的本地机器上没有 cshtml 扩展,页面可以正常工作。

有谁知道如何解决这个问题?

【问题讨论】:

    标签: asp.net wordpress razor url-rewrite-module


    【解决方案1】:

    wordpress 规则之前,添加一条规则来捕获 /app 流量并停止处理规则,如下所示:

    <rule name="razorapp" stopProcessing="true">
        <match url="^app/*"/>
        <action type="None" />
    </rule>
    

    不确定这是否完全正确,但您应该明白这一点。您需要在重写模块处理配置中的 wordpress 规则之前将其短路。

    【讨论】:

    • 这就是缺少的。谢谢保罗!
    猜你喜欢
    • 1970-01-01
    • 2016-06-02
    • 2023-04-02
    • 2011-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-05
    • 2022-11-30
    相关资源
    最近更新 更多