如何从asp.net的URL中删除页面名称? [英] how to remove page name from url in asp.net?

查看:67
本文介绍了如何从asp.net的URL中删除页面名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

来自以下网址:

http://www.mywebsite.com/default.aspx

我想删除default.aspx,以便使网址看起来像这样:

I want to remove the default.aspx so the url will look like :

http://www.mywebsite.com/

我需要一种快速且干净的方法来执行此操作,而只需要使用default.aspx页面而不需要其他页面来执行此操作.预先感谢.

I need a quick and clean way to do this , and I only need to do this with default.aspx page and no ther pages . thanks in advance .

推荐答案

使用以下代码更改您的Web配置:它解决了我的同样问题.

change your webconfig with below code:it solve my same problem.

<?xml version="1.0"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="default.aspx Redirect" stopProcessing="true">
                    <match url="^(.*\/)*default\.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>

这篇关于如何从asp.net的URL中删除页面名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆