busse
busse

Reputation: 1777

ASP.NET URL rewriting for DB query 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 the URL, in a similar way to a wiki, but in this case the site is read-only. An example of a URL I'd like would be:

http://www.foo.com/bar

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

I've looked into many URL re-writer options for IIS6 (and this would be on a dedicated server), but I'm still not sure which one to use for this application.

To perhaps clarify, I only need to run the site from a single default.aspx file, but I want it to work as described above. The overall site logic will be very simple.

I am hoping that someone with more experience in this area can help me out -- I am looking for the simplest solution that will address this one scenario.

Upvotes: 1

Views: 1764

Answers (2)

aracntido
aracntido

Reputation: 253

Just for the record, IIS URL Rewrite 2 supports this, you can install the extensibility samples that include a DB provider. Works on IIS 7+ only.

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

Upvotes: 0

Yona
Yona

Reputation: 9702

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

If you cannot base you database query on a query string parameter (e.g. foo.com/default.aspx?query=bar) then the best you can do on IIS6 is a wildcard mapping. Basically this means that every request will be directed over to asp.net (including images scripts and styles.) obviously this will degrade performance.

To enable wildcard mapping right click on your site in IIS manager and go to Properties -> Home Directory -> Configuration -> Mappings at the bottom click insert and type in the path to the asp.net isapi dll (you can copy it from the aspx extension above) and uncheck 'Verify that file exists'.

After making the changes you'll be able to request foo.com/bar

(another method might be to make a request to foo.com/default.aspx/bar)

Upvotes: 2

Related Questions