Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Handling dynamic "folders" for url-rewrites?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Klaus Jensen - 01 Jul 2007 00:29 GMT
Hi

I created code to allow me to rewrite urls from global.asax, so that if the
incoming Url is for instance:

/Hats/ReallyCoolHat.aspx

...I look up ReallyCoolHat in the products table and rewrite the url to
Product.aspx?id=12 if that is the productId for ReallyCoolHat.

This works, because .aspx-files are handled by Asp.Net, so I can catch
requests in global.asax and rewrite the url, if I want to.

I also know how to set IIS to have Asp.Net handle all kinds of extensions...

But... I also need to do something similar for folders, ie...:

/Hats/

...But this does not have an file-extension, and is not handled by Asp.Net.

How do I make Asp.Net handle this, so I can catch requests to /Hats/ in
global.asax Application_beginrequest?
Masudur - 01 Jul 2007 05:43 GMT
> Hi
>
[quoted text clipped - 19 lines]
> How do I make Asp.Net handle this, so I can catch requests to /Hats/ in
> global.asax Application_beginrequest?

Hi...

Check out this
Scott Guthrie's post on url rewriting...
http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-a
sp-net.aspx


Thanks
Munna
www.kaz.com.bd
www.munnacs.110mb.com
Peter Bromberg [C# MVP] - 01 Jul 2007 22:12 GMT
The bottom line for this "trick" is to create a wildcard ( * ) handler in IIS
that points to the aspnet_Isapi.dll which means that all requests without a
known file extension get sent throug ASP.NET, where you can process using
typical REGEX url-rewriting techniques.
-- Peter
Site:  http://www.eggheadcafe.com
UnBlog:  http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA):    http://www.blogmetafinder.com

> Hi
>
[quoted text clipped - 19 lines]
> How do I make Asp.Net handle this, so I can catch requests to /Hats/ in
> global.asax Application_beginrequest?
Alan Silver - 08 Jul 2007 20:53 GMT
>The bottom line for this "trick" is to create a wildcard ( * ) handler in IIS
>that points to the aspnet_Isapi.dll which means that all requests without a
>known file extension get sent throug ASP.NET, where you can process using
>typical REGEX url-rewriting techniques.

The only problem with that is that it can put an unnecessary strain on
the server as *everything* is then sent through the ASP.NET engine.

Another solution is to create a Hats folde and add a default.aspx file
to it. This file does not need to do anything as the engine will
redirect to the real URL anyway, it's just there to get ASP.NEt to
process the request.

This is only practical if you have a smallish number of folders you want
to use. If you many, or if they change regularly, then this may not be
practical.

You could consider using URLs like /Hats_ReallyCoolHat.aspx which will
save you the hassle, and be better for the search engines as it looks
like a top-level folder instead of a second-level one like you
suggested.

HTH

>-- Peter
>Site:  http://www.eggheadcafe.com
[quoted text clipped - 24 lines]
>> How do I make Asp.Net handle this, so I can catch requests to /Hats/ in
>> global.asax Application_beginrequest?

Signature

Alan Silver
(anything added below this line is nothing to do with me)

Peter Bromberg [C# MVP] - 08 Jul 2007 22:48 GMT
As another alternative, you can map the 404 handler in IIS to 404.aspx where
you can do urlrewriting based on urls like "http://mysite/user/joshmoe" -
with no extension.  I haven't tested this for performance, but it does work -
IIS will call the 404.aspx page and append the requested "bogus" url onto the
querystring.
Peter
Site:  http://www.eggheadcafe.com
UnBlog:  http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA):    http://www.blogmetafinder.com

> >The bottom line for this "trick" is to create a wildcard ( * ) handler in IIS
> >that points to the aspnet_Isapi.dll which means that all requests without a
[quoted text clipped - 48 lines]
> >> How do I make Asp.Net handle this, so I can catch requests to /Hats/ in
> >> global.asax Application_beginrequest?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.