Migrating ASP.NET url to query db from url content without extension

I am trying to create a very simple ASP.NET application that presents information retrieved from a database based on a URL, similar to a wiki, but in this case the site is read-only. An example URL that I would like would be:

http://www.foo.com/bar

      

The application will then use "bar" as a parameter to the SQL query to display information from the database that matches "bar".

I've looked at a lot of URL rewriting options for IIS6 (and it will be on a dedicated server), but I'm still not sure which one to use for this application.

To clarify, I only need to run the site from one file default.aspx

, but I want it to work as described above. The overall site logic will be very simple.

I hope that someone with more experience in this area can help me - I am looking for the simplest solution that will solve this scenario.

+1


source to share


2 answers


IIS6 only directs requests to the asp.net engine if this extension has been registered. By default the registered extensions are aspx ascx asmx etc.

If you cannot use a database query for a query string parameter (e.g. foo.com/default.aspx?query=bar), then the best you can do in IIS6 is wildcard matching. This basically means every request will be redirected to asp.net (including scripts and image styles). Obviously this will degrade performance.

To enable wildcard display, right click on your site in IIS Manager and go to Properties → Home → Configuration → Mappings in the bottom click insert and enter the path to the asp.net isapi dll ( you can copy this from the aspx extension above) and uncheck "Check if file exists".



After making your changes, you can request foo.com/bar

(another way could be requesting foo.com/default.aspx/bar)

+2


source


Write-only IIS URL Rewrite 2 supports this, you can install the extensibility samples that include the database provider. Works with IIS 7+ only.



http://www.iis.net/download/urlrewrite http://code.msdn.microsoft.com/rewriteextensibility

0


source







All Articles