我在 Asp.net 中开发了一个 Web 应用程序。当我通过 IIS 使用应用程序时,文件扩展名 as.aspx 是可见的。是否可以隐藏它(或)重命名它......提前谢谢。
问问题
134 次
2 回答
1
web.config
对于 .NET 框架 4.0+,在(inside )中尝试以下规则<system.webServer>
:
第一个将使用旧格式重定向 URL,以删除.aspx
扩展名。您当然也应该更新您的链接 - 最终您将不需要这个。
第二条规则在内部重写 URL 以.aspx
在幕后添加。
<rewrite>
<rules>
<rule name="RedirectOldFormat" enabled="true" stopProcessing="true">
<match url="(.*)\.aspx" />
<action type="Redirect" url="{R:1}" />
</rule>
<rule name="InternallyAddAspx" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
</rules>
</rewrite>
于 2013-06-20T10:35:23.260 回答
0
对于 .NET Framework 3.5 或更早版本,您可以使用路由来完成此操作。尝试以下解决方案:
于 2013-06-20T11:08:07.490 回答