Search code examples
c#asp.netasp.net-routing

How to cut "/Default.aspx" from URL


Routes are working, but when i start my site up i get

 localhost:57564/Default.aspx

Is there a simple fix for this?


Solution

  • Use a rewrite rule in your web.config file.

    <configuration>
       <system.webServer>
         <rewrite> 
        <rules>   
        <rule name="Default Redirect" stopProcessing="true">
                <match url="^Default\.aspx$" />
                <action type="Redirect" url="/" redirectType="Permanent" />
            </rule>
        </rules>
        </rewrite>
        </system.webServer>
    </configuration>