473,586 Members | 2,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.a spx

....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_beg inrequest?

Jun 30 '07 #1
4 1932
On Jul 1, 5:29 am, "Klaus Jensen" <spammers...@fr omcancer.comwro te:
Hi

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

/Hats/ReallyCoolHat.a spx

...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_beg inrequest?
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.dl l 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.a spx

....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_beg inrequest?

Jul 1 '07 #3
In article <62************ *************** *******@microso ft.com>, "Peter
Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comwrites
>The bottom line for this "trick" is to create a wildcard ( * ) handler in IIS
that points to the aspnet_Isapi.dl l 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_ReallyCool Hat.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.a spx

....I look up ReallyCoolHat in the products table and rewrite the url to
Product.aspx?i d=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_beg inrequest?

--
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************ *************** *******@microso ft.com>, "Peter
Bromberg [C# MVP]" <pb*******@yaho o.yabbadabbadoo .comwrites
The bottom line for this "trick" is to create a wildcard ( * ) handler in IIS
that points to the aspnet_Isapi.dl l 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_ReallyCool Hat.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.a spx

....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_beg inrequest?


--
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
2183
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 an already existing project stored at another location. Unfortunately, VS.NET doesn't seem to support double names in the "recent files" list: only...
235
11613
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 stay with C and still be able to produce Java byte code for platform independent apps. Also, old programs (with some tweaking) could be...
4
2326
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 horizontal ones on TOP of the page. I figured it out and have it working fine, except for one thing--apparently I need to insert the code for the menu...
1
1736
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 new folders has name like: "db2admin", "db2admin.MACHINENAME", "db2admin.MACHINENAME.001", "db2admin.MACHINENAME.002", ... Can any one help me with...
1
4866
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 the current directory to verify it's not "System Volume Information" ? Or, how to catch this error and continue the process when the error occurs...
9
13703
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: Could not find a part of the path "D:\". The full path is "D:\hshome\clinton\test.gotchasoft.com\verify" The web is running using impersonation as a...
2
1051
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 only. I have a simple class that needs to be accessible to the two subfolders mentioned above. I placed this class in App_Code and declared it...
8
4421
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? Thanks in advance for any helpful suggestions
3
1646
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 a logfile with exceptions that happens when they test the program on the server. I'm using VS2005, VB.NET, XP Pro, CDO 1.21 dll Anyway, this...
0
7911
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8215
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.