473,320 Members | 1,982 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,320 software developers and data experts.

Custom HTTP Handler in 2.0

If I understand correctly, I can write a custom handler for a given
extension (say .abcd files) by writing a class that implements the
IHttpHandler interface and then registering it in my web config file.
Once I do that, how do I differentiate between different pages with
the abcd extension, and write specific code for each page? (And keep
that code with the page, similar to codebehind.?)

Thanks,
Bryan
Nov 20 '05 #1
5 1791
After you register the .abcd extension in IIS by configurating it to be
handled by aspnet_isapi.dll, you really don't have to write physical
files with .abcd extension. All your files would be .cs or .vb files
and they would have their own class names.

To really answer your question, you would probably have to create a
Page Handler Factory of classes. Probably utilize IHttpHandlerFactory.

See
http://msdn.microsoft.com/library/de...classtopic.asp

Nov 20 '05 #2
Once you have a handler, the handler is responsible entirely for the
processing. How you handle the different page names is entirely up to you.

From what you're asking, it seems that you don't want a custom HttpHandler;
you just want pages with a .abcd extension to be handled by ASP.Net page
classes. For that, all you need to do is configure IIS to hand off requests
for pages with that extension to the ASP.Net ISAPI.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

<br***@newsgroups.nospam> wrote in message
news:c3********************************@4ax.com...
If I understand correctly, I can write a custom handler for a given
extension (say .abcd files) by writing a class that implements the
IHttpHandler interface and then registering it in my web config file.
Once I do that, how do I differentiate between different pages with
the abcd extension, and write specific code for each page? (And keep
that code with the page, similar to codebehind.?)

Thanks,
Bryan

Nov 20 '05 #3
If all Bryan wants to do is add a specific extension ( .abcd ) to the
pages which are served by his server, he can use this in web.config:

<httpHandlers>
<add verb="GET, HEAD, POST, DEBUG" path="*.abcd" type="System.Web.UI.PageHandlerFactory"/>
</httpHandlers>
<compilation>
<buildProviders>
<add extension=".abcd" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>

and map the extension .abcd to aspnet_isapi.dll in the
Application's configuration section in the Internet Service Manager.

That will cause ASP.NET to process the .abcd extension
in the exact same way it processes files with the .aspx extension.

That means that, if the page is named "whatever.abcd", the corresponding
codebehind pages would need to be named : "whatever.abcd.cs" or "whatever.abcd.vb".



Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message news:O2**************@TK2MSFTNGP15.phx.gbl...
Once you have a handler, the handler is responsible entirely for the
processing. How you handle the different page names is entirely up to you.

From what you're asking, it seems that you don't want a custom HttpHandler;
you just want pages with a .abcd extension to be handled by ASP.Net page
classes. For that, all you need to do is configure IIS to hand off requests
for pages with that extension to the ASP.Net ISAPI.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

<br***@newsgroups.nospam> wrote in message
news:c3********************************@4ax.com...
If I understand correctly, I can write a custom handler for a given
extension (say .abcd files) by writing a class that implements the
IHttpHandler interface and then registering it in my web config file.
Once I do that, how do I differentiate between different pages with
the abcd extension, and write specific code for each page? (And keep
that code with the page, similar to codebehind.?)

Thanks,
Bryan


Nov 20 '05 #4

Kevin Spencer wrote:
From what you're asking, it seems that you don't want a custom HttpHandler;
you just want pages with a .abcd extension to be handled by ASP.Net page
classes. For that, all you need to do is configure IIS to hand off requests
for pages with that extension to the ASP.Net ISAPI.

Doing it this way is fine. But, you would loose all IDE features that
VS.2005 provides since its doesn't understand the .abcd extension. But
if you write all your pages as .cs class files that inherit from
IHttpHandler then you can get the intellisense and other IDE
enhancements.

Nov 20 '05 #5
I should have added that's an ASP.NET 2.0-specific solution.
It's a bit simpler in ASP.NET 1.1.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uu**************@TK2MSFTNGP09.phx.gbl...
If all Bryan wants to do is add a specific extension ( .abcd ) to the
pages which are served by his server, he can use this in web.config:

<httpHandlers>
<add verb="GET, HEAD, POST, DEBUG" path="*.abcd" type="System.Web.UI.PageHandlerFactory"/>
</httpHandlers>
<compilation>
<buildProviders>
<add extension=".abcd" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>

and map the extension .abcd to aspnet_isapi.dll in the
Application's configuration section in the Internet Service Manager.

That will cause ASP.NET to process the .abcd extension
in the exact same way it processes files with the .aspx extension.

That means that, if the page is named "whatever.abcd", the corresponding
codebehind pages would need to be named : "whatever.abcd.cs" or "whatever.abcd.vb".

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:O2**************@TK2MSFTNGP15.phx.gbl...
Once you have a handler, the handler is responsible entirely for the
processing. How you handle the different page names is entirely up to you.

From what you're asking, it seems that you don't want a custom HttpHandler;
you just want pages with a .abcd extension to be handled by ASP.Net page
classes. For that, all you need to do is configure IIS to hand off requests
for pages with that extension to the ASP.Net ISAPI.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

<br***@newsgroups.nospam> wrote in message
news:c3********************************@4ax.com...
If I understand correctly, I can write a custom handler for a given
extension (say .abcd files) by writing a class that implements the
IHttpHandler interface and then registering it in my web config file.
Once I do that, how do I differentiate between different pages with
the abcd extension, and write specific code for each page? (And keep
that code with the page, similar to codebehind.?)

Thanks,
Bryan

Nov 20 '05 #6

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

Similar topics

3
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
0
by: Søren Lund | last post by:
Hello, I have implemented a custom config section handler by implementing the IConfigurationSectionHandler interface. I have registered this handler in web.config and everything works fine ......
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
6
by: Tabi | last post by:
Hi, I want to create a custom section in my web.config that can hold my custom values. I created a section in web.config as written below. <configSections> <section name="myCustomSection"...
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
2
by: Laurent Bugnion | last post by:
Hi, I like to develop custom controls for a number of webpages. These controls are often customizable, so that they can be reused in a number of situations. My question is: What is the best...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
0
by: Jordan S. | last post by:
Using .NET 3.5... in a "plain old" .aspx page I have the following code in the Init event: this.Context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.