【问题标题】:How to Hide .aspx extension from Browser in Asp.net [duplicate]如何在 Asp.net 的浏览器中隐藏 .aspx 扩展名 [重复]
【发布时间】:2018-02-16 05:05:37
【问题描述】:

我在 Asp.net C#, SQL-Server 2005 中创建了一个网站。

我的要求是我不想在浏览器中显示扩展名 .aspx

例如,我有 Products.aspx 页面,我想在浏览器中显示这些产品。

请帮帮我。

【问题讨论】:

标签: c# asp.net


【解决方案1】:

试试这些对你有帮助..

 <configuration>
    <system.webserver>
    <rewrite>
    <rules>
        <rule name="extensionless" stopprocessing="true">
              <match url="(.*)\.html$" />
              <action type="Redirect" url="{R:1}" redirecttype="Permanent" />
        </rule>
        <rule name="removeextension" 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}.html" />
        </rule>
    </rules>
    </rewrite>
    </system.webserver>
    </configuration>

【讨论】:

    【解决方案2】:

    像这样更改您的 webconfig 文件:

    <?xml version="1.0"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Product.aspx Redirect" stopProcessing="true">
                        <match url="^(.*\/)*Product\.aspx$" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{REQUEST_METHOD}" negate="true" pattern="^POST$" />
                        </conditions>
                        <action type="Redirect" url="{R:1}" redirectType="Permanent"/>
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>
    

    【讨论】:

      猜你喜欢
      • 2012-11-18
      • 1970-01-01
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      • 2012-01-12
      • 2012-06-16
      • 2010-09-18
      相关资源
      最近更新 更多