PDA

View Full Version : How pages are displayed without extension .aspx


chpraveen.80
06-30-2006, 04:00 PM
Hi guys,

I see some web sites which are developed on ASP.Net platform. But when i browse each and every page, it will not have .aspx extension. Any setting is given?

otaku149
06-30-2006, 05:10 PM
Hi,

In ASP.Net 2.0, you can use url rewriting. Let's create a basic sample with 2 page (page1.aspx and page2.aspx):

page1.aspx

<form id="form1" runat="server">
<div>
<h1>Page 1</h1>
</div>
<div>
<a href="page2">Go to Page 2</a>
</div>
</form>


page2.aspx

<form id="form1" runat="server">
<div>
<h1>Page 2</h1>
</div>
<div>
<a href="page1">Go to Page 1</a>
</div>
</form>


Add the following code in your web.config between <system.web> and </system.web>

<urlMappings enabled="true">
<add url="~/page1" mappedUrl="~/page1.aspx" />
<add url="~/page2" mappedUrl="~/page2.aspx" />
</urlMappings>


To rewrite more complex URL or website with many many pages, you may use the following free open source url rewriting component:
http://www.urlrewriting.net

This will rewrite complex URL such as:
http://yourdomain.com/page.aspx?m=3&c=18&r=696

Result:
http://yourdomain.com/3/18/page696

chpraveen.80
07-01-2006, 04:38 PM
Thank you otaku149.

This helped me better.

otaku149
07-02-2006, 11:26 PM
Thank you otaku149.

This helped me better.

You're welcome :)

A1ien51
07-05-2006, 03:58 PM
plus you can set it up as index.aspx or default.aspx (depends on server setting) and that allows you to use the directory level as the page. Just like how your main page of your site works.

Eric

CurtWRC
07-07-2006, 02:18 AM
Sorry to hijack the thread, but Ive just tired this in my web.config file and it didn't work. Are there any possible reasons for this? I just got an error page.

otaku149
07-07-2006, 04:34 AM
which error exactly?

CurtWRC
08-25-2006, 07:31 PM
which error exactly?

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

otaku149
08-29-2006, 11:11 PM
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Hello Curt,

I attached the sample project UrlRewriting.zip