问题 当我尝试使用 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 扩展即可正常工作。
有人知道如何解决这个问题吗?
最佳答案
在 wordpress 规则之前,添加一条规则来捕获 /app 流量并停止处理规则,如下所示:
<rule name="razorapp" stopProcessing="true">
<match url="^app/*"/>
<action type="None" />
</rule>
不确定这是否完全正确,但您应该明白了。您需要先短路重写模块,然后才能处理配置中的 wordpress 规则。
关于asp.net - 如何在 Wordpress 下使用 Razor 托管 ASP.NET 网页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9338013/