473,326 Members | 2,813 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,326 software developers and data experts.

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 1257
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
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
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
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
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
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
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
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
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
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
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
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...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.