473,503 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpHandlers and HTTPModules

I need to handle all http requests so that if someone types something like

http://www.mysite.com/123

then I would load the article 123

I can't get this to work because the app keeps looking for a folder called
123 and my custom handlers and modules are not getting called.

Although if I type http://www.mysite.com/123.aspx then my custom handlers
are getting called.

How do I fix this?

Thanks.

- Emad
Nov 18 '05 #1
5 1259
You cannot map a blank extension to be run by asp.net (i.e in your
httpmodule), so the only way I have found to manage this is to create a
custom 404 page which checks if the 404 is caused by the situation you
describe (in its simplest form just checking if the request ends with
..aspx), you can then redirect to the appropriate page using a
Response.Redirect.

As far as I know this really is the only way around this problem,
although I am aware it isn't the most elegant it does solve the problem.

HTH

Matt
"Emad Ibrahim" <ie***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I need to handle all http requests so that if someone types something like
http://www.mysite.com/123

then I would load the article 123

I can't get this to work because the app keeps looking for a folder called 123 and my custom handlers and modules are not getting called.

Although if I type http://www.mysite.com/123.aspx then my custom handlers are getting called.

How do I fix this?

Thanks.

- Emad

Nov 18 '05 #2
Hello Emad,
I need to handle all http requests so that if someone types something
like

http://www.mysite.com/123

then I would load the article 123


Look into HttpContext.RewritePath (http://msdn.microsoft.com/library/de...pathtopic.asp).

"Assigns an internal rewrite path. RewritePath allows for the URL that is requested to differ from the internal path to the resource. RewritePath is used in cookieless session state."

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #3
That's not going to work because the page never fires... The problem is
that by calling http://www.mysite.com/123 the code never runs because it is
all trapped in IIS which is looking for a subfolder called 123...

-Emad
"Matt Berther" <mb******@hotmail.com> wrote in message
news:uP**************@TK2MSFTNGP09.phx.gbl...
Hello Emad,
I need to handle all http requests so that if someone types something
like

http://www.mysite.com/123

then I would load the article 123
Look into HttpContext.RewritePath

(http://msdn.microsoft.com/library/de...-us/cpref/html
/frlrfsystemwebhttpcontextclassrewritepathtopic.asp ).
"Assigns an internal rewrite path. RewritePath allows for the URL that is requested to differ from the internal path to the resource. RewritePath is
used in cookieless session state."
--
Matt Berther
http://www.mattberther.com

Nov 18 '05 #4
That doesn't work because the 404 page never runs inside the application.
The 404 page is just a redirect in IIS, which means I can't handle any
events in the page, hence I won't be able to load the articles based on the
URL

"matt" <gr************@hitscricket.com> wrote in message
news:ho*********************@wards.force9.net...
You cannot map a blank extension to be run by asp.net (i.e in your
httpmodule), so the only way I have found to manage this is to create a
custom 404 page which checks if the 404 is caused by the situation you
describe (in its simplest form just checking if the request ends with
.aspx), you can then redirect to the appropriate page using a
Response.Redirect.

As far as I know this really is the only way around this problem,
although I am aware it isn't the most elegant it does solve the problem.

HTH

Matt
"Emad Ibrahim" <ie***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I need to handle all http requests so that if someone types something

like

http://www.mysite.com/123

then I would load the article 123

I can't get this to work because the app keeps looking for a folder

called
123 and my custom handlers and modules are not getting called.

Although if I type http://www.mysite.com/123.aspx then my custom

handlers
are getting called.

How do I fix this?

Thanks.

- Emad


Nov 18 '05 #5
That's not strictly true, if you specify the 404 page in IIS the
requested page is forwarded in the querystring so in your example if
your setup 404.aspx as a redirect URL, the called page will be
404.asp?404;http://www.mysite.com/123. This means that you can then
retrieve the requested url in the 404 page with some code similar to the
following. It does with work because we use it!

string RequestedUrl = Request.QueryString.ToString().Replace("404;);
if(RequestedUrl.EndsWith(".aspx") {
// assume this is a request for a folder...
Response.Redirect(RequestedUrl + ".aspx");
} else {
// assume this is an actual 404 error and do the required
processing;
}

This will ultimately result in a request for http://www.mysite.com/123
being forwarded to http://www.mysite.com/123.aspx

Matt
http://www.3internet.co.uk
"Emad Ibrahim" <ie***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
That doesn't work because the 404 page never runs inside the application. The 404 page is just a redirect in IIS, which means I can't handle any
events in the page, hence I won't be able to load the articles based on the URL

"matt" <gr************@hitscricket.com> wrote in message
news:ho*********************@wards.force9.net...
You cannot map a blank extension to be run by asp.net (i.e in your
httpmodule), so the only way I have found to manage this is to create a custom 404 page which checks if the 404 is caused by the situation you describe (in its simplest form just checking if the request ends with .aspx), you can then redirect to the appropriate page using a
Response.Redirect.

As far as I know this really is the only way around this problem,
although I am aware it isn't the most elegant it does solve the problem.
HTH

Matt
"Emad Ibrahim" <ie***********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I need to handle all http requests so that if someone types
something like

http://www.mysite.com/123

then I would load the article 123

I can't get this to work because the app keeps looking for a
folder called
123 and my custom handlers and modules are not getting called.

Although if I type http://www.mysite.com/123.aspx then my custom

handlers
are getting called.

How do I fix this?

Thanks.

- Emad



Nov 18 '05 #6

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

Similar topics

0
1688
by: some guy with a computer | last post by:
I can not get a custom httpHandler to fire using machine.config and an assembly in the GAC. It will not work if I move the assembly to the GAC, even though I have it referenced correctly and add...
0
1241
by: Chance Hopkins | last post by:
Does anyone know how to get a custom httpHandler to fire for all applications in machine.config for an assembly in the GAC, without using seperate location tags? For instance, this works for a...
1
2678
by: Steen Tøttrup | last post by:
This is what I'm doing: I'm using Httpmodules and Httphandlers to control access to files (images, movies, etc.), but have run into quite a problem when several files are being requested at the...
3
2110
by: MWells | last post by:
I'm having an issue getting my HttpHandlers and HttpModules to play together nicely. My HttpHandlers take special document types (defined by extension) and process them specially. I might have...
11
1532
by: Markus Kling | last post by:
Hi, I have a web application that has two sub-applications. The root application defines two httpModules which shall not be loaded for the subapplications. I tried to achieve this by adding ...
0
1156
by: tshad | last post by:
I have 2 controls that I need to run that I got of the Web. I have been using ScrollKeeper for awhile and was trying to add FreeTextBox to my site. But for some reason it won't run if ScrollKeeper...
5
1988
by: Anonieko | last post by:
HttpHandlers - Learn Them. Use Them. Introduction There are many features in ASP.NET that are unfortunately underused. Sometimes a feature gets looked over because it's too complicated....
1
1906
by: Asela Gunawardena | last post by:
Hi all, we have a webservice as a seperate virtual directory placed under a Web Site named GRSCS in IIS. Both are .NET applications and uses MS application blocks as the data layer. Recently an...
3
2119
by: =?Utf-8?B?Tm9yZW1hYw==?= | last post by:
Hi, We are writing a Web SSO service for all of our websites through Forms Authentication. We also want to provide our websites with the ability to protect different parts of their website and...
0
1074
by: =?Utf-8?B?UmF5?= | last post by:
Nearly all examples of writing HttpModules and HttpHandlers create them in new assemblies. We have a lot of our common code in our "Web.Framework" assembly - if we wrote all our modules and...
0
7093
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...
0
7287
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,...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
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...
0
4689
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...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
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 ...
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.