Remove home page name from Url in ASP.Net

Bhavesh23
 
on Oct 28, 2021 04:03 AM
549 Views

i want to display website name in the url bar as well as my website name like www.webname.com  

when user navigate to main home page then the website name should be display into url bar.

urlRouting.MapPageRoute("", "Home", "~/Home.aspx");

i have used as above to navigate on home page.

Download FREE API for Word, Excel and PDF in ASP.Net: Download
dharmendr
 
on Oct 28, 2021 04:06 AM

Hi Bhavesh23,

Change your webconfig with below code:

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

Reference:

https://stackoverflow.com/questions/17399220/how-to-remove-page-name-from-url-in-asp-net/21598770