473,807 Members | 2,766 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1810
After you register the .abcd extension in IIS by configurating it to be
handled by aspnet_isapi.dl l, 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 IHttpHandlerFac tory.

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***@newsgrou ps.nospam> wrote in message
news:c3******** *************** *********@4ax.c om...
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.We b.UI.PageHandle rFactory"/>
</httpHandlers>
<compilation>
<buildProviders >
<add extension=".abc d" type="System.We b.Compilation.P ageBuildProvide r" />
</buildProviders>
</compilation>

and map the extension .abcd to aspnet_isapi.dl l 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***@DIESPAMM ERSDIEtakempis. com> wrote in message news:O2******** ******@TK2MSFTN GP15.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***@newsgrou ps.nospam> wrote in message
news:c3******** *************** *********@4ax.c om...
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******** ******@TK2MSFTN GP09.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.We b.UI.PageHandle rFactory"/>
</httpHandlers>
<compilation>
<buildProviders >
<add extension=".abc d" type="System.We b.Compilation.P ageBuildProvide r" />
</buildProviders>
</compilation>

and map the extension .abcd to aspnet_isapi.dl l 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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:O2******** ******@TK2MSFTN GP15.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***@newsgrou ps.nospam> wrote in message
news:c3******** *************** *********@4ax.c om...
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
3769
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 class. If is attached I want to perform some action. How can I access custom attributes from an HttpModule? I have to pass a target to the System.Attribute.GetCustomAttribute() call to attempt to retrieve the attached attribute. I tried to access...
0
1851
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 ... for a while. At random points in time my section handler stops working and throws the exception: Configuration Error Description: An error occurred during the processing of a configuration
7
2925
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="*" path="*.sgf" type="CustomExtensionHandler, Extenders.CustomExtensionHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d831d925597c1031" validate="True"/> </httpHandlers>
6
3805
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" type="ComIT.Applications.Common.ConfigurationSections.MyHandler" allowLocation="true" allowDefinition="Everywhere" /> </configSections>
8
3914
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 need to avoid the extra round-trip to the client. I've tried Passing the page name, the full URL, and the instance of the handler class to the Transfer method, but everything gets me the same error 500. Any help would be appreciated.
2
1540
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 practice for configuring a custom control. As far as I can say, I have the following alternatives: - Defining properties for the control, and setting these in the ASPX
2
5117
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 = Windows Forms class B = a singleton hosted within A. B is responsible for dynamically loading classes X, Y, and Z.
0
1387
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)); this.Context.Response.Cache.SetCacheability(HttpCacheability.Public); this.Context.Response.Cache.SetValidUntilExpires(false); It works great. Testing shows that the page is cached for 60 seconds as expected. Specifically, I insert the current date/time into the Response...
2
19500
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
2897
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 will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge. I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
0
9719
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6877
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4330
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
2
3853
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.