473,322 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Handling dynamic "folders" for url-rewrites?

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?

Jun 30 '07 #1
4 1928
On Jul 1, 5:29 am, "Klaus Jensen" <spammers...@fromcancer.comwrote:
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?
Hi...

Check out this
Scott Guthrie's post on url rewriting...
http://weblogs.asp.net/scottgu/archi...h-asp-net.aspx

Thanks
Munna
www.kaz.com.bd
www.munnacs.110mb.com

Jul 1 '07 #2
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

"Klaus Jensen" wrote:
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?

Jul 1 '07 #3
In article <62**********************************@microsoft.co m>, "Peter
Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrites
>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
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com

"Klaus Jensen" wrote:
>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?

--
Alan Silver
(anything added below this line is nothing to do with me)
Jul 8 '07 #4
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

"Alan Silver" wrote:
In article <62**********************************@microsoft.co m>, "Peter
Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrites
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
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com

"Klaus Jensen" wrote:
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?


--
Alan Silver
(anything added below this line is nothing to do with me)
Jul 8 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Konrad L. M. Rudolph | last post by:
I hope this is the right NG, please notify me if not. I have got a problem with the "recent files" list of the start page in VS.NET: yesterday I created a new projekt which has the same name as...
235
by: napi | last post by:
I think you would agree with me that a C compiler that directly produces Java Byte Code to be run on any JVM is something that is missing to software programmers so far. With such a tool one could...
4
by: Larry R Harrison Jr | last post by:
I have them working now, courtesy of the link given in the prior thread--the HVMenu over at Dynamic Drive myself. http://www.dynamicdrive.com I have them working as side-bar menus, not...
1
by: Xiaopeng Qu | last post by:
Hi, I installed DB2 8.1 Express on the WindowsXP, and when I begin to use it, I found DB2 creates many new folders in C:\Documents and Settings. It creats more and more folders every day. All...
1
by: Krazitchek | last post by:
Hi, i check all directories on a disk but an error occurs when i try to enter in the "System Volume Information" directory. Is there a way to "jump" this directory without to check the name of...
9
by: Clinton Frankland | last post by:
Hi, On a Windows 2000 Server when attempting to use System.IO.Directory.CreateDirectory(string.concat(Server.MapPath(""), "\verify")) I receive a System.IO.DirectoryNotFoundException error:...
2
by: Johnny Meredith | last post by:
Warning: Tenderfoot I'm playing around with ASP.Net 2.0 b2. The web app I've created has a default, login, recovery, etc. pages in the root and two folders accessible to authenticated users...
8
by: Just Me | last post by:
1)How can I find the folders like "My Recent Document", "Desktop", "My Pictures",... if I want to store a file there? 2) How can I find the icon for those files if I want to display it? ...
3
by: toyaxxx | last post by:
Hello guys, I have hit a dead end in trying to solve this problem. The thing is, I can't run the the program here because it has to run on a server which is in another place. All I receive here is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.