0

I have Created a WEBSITE in Asp.net C#, SQL-Server 2005.

My Requirement is I don't want to Display the Extension .aspx in browser.

For Example, I have Products.aspx page from these I want to display the products in browser.

Please help me.

hitesh panwar
  • 40
  • 1
  • 10
  • Switch to asp.net mvc. No better solution than that. – Chetan Sep 07 '17 at 12:54
  • Install the IIS rewrite module and do this: https://stackoverflow.com/questions/6097592/removing-aspx-from-pages-using-rewritemodule – VDWWD Sep 07 '17 at 13:01
  • You actually have two options: ASP.NET routing and URL rewriting. You can find a comparison here: https://stackoverflow.com/questions/90112/iis-url-rewriting-vs-url-routing – Ruud Helderman Sep 07 '17 at 13:21

2 Answers2

2

Change your webconfig file like this:

<?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>
1

Try these it will help you..

 <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>
Sandeep Suthar
  • 57
  • 1
  • 12