ts0

ts0

too simplistic

follow me on Twitter!

Extension-Less URL Rewriting in IIS6 without 3rd Party ISAPI

That title is a bit of a mouthful, but it sums up the issue. Everyone seems to be talking about hackable URLs these days, and it kind of feels like the RoR guys are laughing at us ASP.NET people. It's just such a pain to get it to work right in ASP. They added the RewritePath method which you can call in a BeginRequest handler to redirect the request to a certain script and add on any querystring you want, totally transparent to the user. It's a good start.

The problem is that BeginRequest only fires for requests that come through to the ASP.NET engine, that means that IIS has to pick up on an extension like aspx which is mapped to that handler. So most examples of URL rewriting will offer a hackable URL like /shop/books/fiction.aspx, I can hear the RoR guys chuckling again.

After a lot of digging around I came across what seems to be a very little known solution, wildcard mapping. Basically you can add an application mapping to '.*' in the application config and all requests will go to the ASP.NET engine.

I found one little reference to this in some blog comments by Scott Guthrie, he said the problem with this solution is you can't override the default document on a folder, but if that document is aspx then it doesn't really matter!

Anyway, I saved myself $99 on ISAPI Rewrite, so I'm happy.

Labels: ,

4 Comments

Label for input in ASP.NET

Another ASP.NET 2 "secret" for you, this one courtesy of Ben Wards presentation at BarCamp.
AssociatedControlID will automatically write out the for attribute on the label. Saves you waiting till PreRender to get the right ClientId, and keeps UI logic where it should be. Obviously it's a label element and not a span which is what asp:label normally writes out.

Labels:

3 Comments

Default button in ASP.NET

I just had to share this little tip with you. A really annoying problem in ASP.NET 1.1 caused by the fact WebForms are just one big HTML form, is that when you hit enter you never really know what's going to happen, and it's rarely what you wanted. For example, you have a search box and a search button, the search method is attached to the click event of the button. User comes a long, types his query, hits enter, the browser then posts back the form, but hasn't triggered any button clicks. In old multiformed applications you'd have a seperate form for the search control, and the browser would have triggered a click action on the single button in that form (the search button).

Thankfully ASP.NET 2 has a solution for this, you can surround your control in an asp:panel and set a button in it as the default button, then if the user hits enter while focus is on any control in that panel, that button is triggered.

Scott Guthrie has an article on it here.

Labels:

1 Comment
ts0
Thom Shannon's background in making chips gives him a unique insight into the web development industry. As the Technical Director of Glow New Media he works with clients across the UK to deliver high quality web marketing solutions using the latest techniques, accessibility practices, and web standards in both straight and crinkle cut.


Download a vCard (for Outlook)

Friends



Find Me (and my Social Graph)



RSS Feed

Archives 08.06 09.06 10.06 11.06 12.06 01.07 02.07 03.07 04.07 05.07 06.07 07.07 08.07 09.07 10.07 11.07 12.07 01.08 02.08 03.08 04.08



Thomas Shannon-Smith
Tom Shannon-Smith
Tom Shannon
Thom Shannon-Smith