473,569 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTTP handlers WEB.CONFIG syntax, please !

Hello. I have this code in a project named ProductsHandler :

First, a class called ProductsHandler .vb (this particular code is not
important in this question, because the class is correct - it implements
both IHttpHandler.Pr ocessRequest and IHttpHandler.Is Reusable). Anyway, here
it is:
---------------------------------------------------------------------------------------
Imports System.Data.Sql Client
Imports System.Web
Imports System.Data

Public Class ProductsHandler
Implements IHttpHandler

Public Sub ProcessRequest( ByVal objContext As HttpContext) Implements
IHttpHandler.Pr ocessRequest

Dim intProductID As Integer
Dim objConn As New SqlConnection()
Dim objCommand As SqlCommand
Dim objDataReader As SqlDataReader
Dim strSelect As String

Try
intProductID = GetProductID(ob jContext.Reques t.Path)
strSelect = "Select ProductName, UnitPrice from Products where
ProductID=@Prod uctID"
objCommand = New SqlCommand(strS elect, objConn)
objCommand.Para meters.Add("@Pr oductID", intProductID)
objConn.Connect ionString =
ConfigurationSe ttings.AppSetti ngs("strConn")
objConn.Open()
objDataReader = objCommand.Exec uteReader(Comma ndBehavior.Sing leRow)
If objDataReader.R ead Then
objContext.Resp onse.Write("<h2 >Product Name: </h2>")
objContext.Resp onse.Write(objD ataReader("Prod uctName"))
objContext.Resp onse.Write("<h2 >Product Price: </h2>")
objContext.Resp onse.Write(Stri ng.Format("{0,c }",
objDataReader(" UnitPrice")))
End If
objConn.Close()
Catch ex As Exception

Finally
objConn.Dispose ()
objCommand.Disp ose()
End Try
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.Is Reusable

Get
Return True
End Get
End Property

Private Function GetProductID(By Val strPath As String) As Integer 'Not
finished yet

Return 19
End Function

End Class
---------------------------------------------------------------------------------------
And this is the beginning of my web.config file:
---------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>
<appSettings>
<add key="strConn" value="server=r adu;database=wo rkdb;integrated
security=SSPI;" ></add>
</appSettings>

<system.web>
<httpHandlers >
<add verb="*" path="*"
type="ProductsH andler,Products Handler"></add>
</httpHandlers>

<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to insert debugging symbols (.pdb
information)
into the compiled page. Because this creates a larger file that
executes.....
---------------------------------------------------------------------------------------

I build the project and I see in the folder "C:\Documen ts and
Settings\Admini strator\My Documents\My
Projects\ASPNET Projects\VSNet\ ProductsHandler \bin" that there is a file
named ProductsHandler .dll. Correct. I open IIS and I check that my folder
"ASPNETProjects \VSNet\Products Handler" is really a virtual folder. It is.
The rights are there and correct, as well.

I expect to open IE and to see the product with ID=19 listed on my page. So
I type the address (it is a correct address !)

http:\\localhos t\aspnetproject s\vsnet\Product sHandler\Produc t1.aspx

and I get...

Parser Error Message: Could not load type ProductsHandler from assembly
ProductsHandler .

So the question is, please, what's wrong with my "path" in web.config ?

Thank you, Alex.
Nov 19 '05 #1
3 1947
Sorry, in the previous post I have misspelled the address I'm using - it
should be:
http://localhost/aspnetprojects/vsne.../Product1.aspx
instead of
http:\\localhos t\aspnetproject s\vsnet\Product sHandler\Produc t1.aspx
Nov 19 '05 #2
Hey Alex,
I can give this more of a look, but my initial thought is that your
ProductHandler class is actually within a namespace - namely the name of
your project. However, in your web.config you are simply looking for
ProductHandler. ...in other words, change your web.config to do
ProjectName.Pro ductHandler,Pro ductHandler

Just a quick guess, lemme know...if I'm wrong I'll look more @ it.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"msnews.microso ft.com" <RE************ ***********@yah oo.com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello. I have this code in a project named ProductsHandler :

First, a class called ProductsHandler .vb (this particular code is not
important in this question, because the class is correct - it implements
both IHttpHandler.Pr ocessRequest and IHttpHandler.Is Reusable). Anyway,
here it is:
---------------------------------------------------------------------------------------
Imports System.Data.Sql Client
Imports System.Web
Imports System.Data

Public Class ProductsHandler
Implements IHttpHandler

Public Sub ProcessRequest( ByVal objContext As HttpContext) Implements
IHttpHandler.Pr ocessRequest

Dim intProductID As Integer
Dim objConn As New SqlConnection()
Dim objCommand As SqlCommand
Dim objDataReader As SqlDataReader
Dim strSelect As String

Try
intProductID = GetProductID(ob jContext.Reques t.Path)
strSelect = "Select ProductName, UnitPrice from Products where
ProductID=@Prod uctID"
objCommand = New SqlCommand(strS elect, objConn)
objCommand.Para meters.Add("@Pr oductID", intProductID)
objConn.Connect ionString =
ConfigurationSe ttings.AppSetti ngs("strConn")
objConn.Open()
objDataReader = objCommand.Exec uteReader(Comma ndBehavior.Sing leRow)
If objDataReader.R ead Then
objContext.Resp onse.Write("<h2 >Product Name: </h2>")
objContext.Resp onse.Write(objD ataReader("Prod uctName"))
objContext.Resp onse.Write("<h2 >Product Price: </h2>")
objContext.Resp onse.Write(Stri ng.Format("{0,c }",
objDataReader(" UnitPrice")))
End If
objConn.Close()
Catch ex As Exception

Finally
objConn.Dispose ()
objCommand.Disp ose()
End Try
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.Is Reusable

Get
Return True
End Get
End Property

Private Function GetProductID(By Val strPath As String) As Integer 'Not
finished yet

Return 19
End Function

End Class
---------------------------------------------------------------------------------------
And this is the beginning of my web.config file:
---------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>
<appSettings>
<add key="strConn" value="server=r adu;database=wo rkdb;integrated
security=SSPI;" ></add>
</appSettings>

<system.web>
<httpHandlers >
<add verb="*" path="*"
type="ProductsH andler,Products Handler"></add>
</httpHandlers>

<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to insert debugging symbols (.pdb
information)
into the compiled page. Because this creates a larger file that
executes.....
---------------------------------------------------------------------------------------

I build the project and I see in the folder "C:\Documen ts and
Settings\Admini strator\My Documents\My
Projects\ASPNET Projects\VSNet\ ProductsHandler \bin" that there is a file
named ProductsHandler .dll. Correct. I open IIS and I check that my folder
"ASPNETProjects \VSNet\Products Handler" is really a virtual folder. It is.
The rights are there and correct, as well.

I expect to open IE and to see the product with ID=19 listed on my page.
So I type the address (it is a correct address !)

http:\\localhos t\aspnetproject s\vsnet\Product sHandler\Produc t1.aspx

and I get...

Parser Error Message: Could not load type ProductsHandler from assembly
ProductsHandler .

So the question is, please, what's wrong with my "path" in web.config ?

Thank you, Alex.

Nov 19 '05 #3
Thank you, Karl - that was it :-))))) Now I know !

Thanks a lot, once again. Alex.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:et******** ******@TK2MSFTN GP11.phx.gbl...
Hey Alex,
I can give this more of a look, but my initial thought is that your
ProductHandler class is actually within a namespace - namely the name of
your project. However, in your web.config you are simply looking for
ProductHandler. ...in other words, change your web.config to do
ProjectName.Pro ductHandler,Pro ductHandler

Just a quick guess, lemme know...if I'm wrong I'll look more @ it.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"msnews.microso ft.com" <RE************ ***********@yah oo.com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hello. I have this code in a project named ProductsHandler :

First, a class called ProductsHandler .vb (this particular code is not
important in this question, because the class is correct - it implements
both IHttpHandler.Pr ocessRequest and IHttpHandler.Is Reusable). Anyway,
here it is:
---------------------------------------------------------------------------------------
Imports System.Data.Sql Client
Imports System.Web
Imports System.Data

Public Class ProductsHandler
Implements IHttpHandler

Public Sub ProcessRequest( ByVal objContext As HttpContext) Implements
IHttpHandler.Pr ocessRequest

Dim intProductID As Integer
Dim objConn As New SqlConnection()
Dim objCommand As SqlCommand
Dim objDataReader As SqlDataReader
Dim strSelect As String

Try
intProductID = GetProductID(ob jContext.Reques t.Path)
strSelect = "Select ProductName, UnitPrice from Products where
ProductID=@Prod uctID"
objCommand = New SqlCommand(strS elect, objConn)
objCommand.Para meters.Add("@Pr oductID", intProductID)
objConn.Connect ionString =
ConfigurationSe ttings.AppSetti ngs("strConn")
objConn.Open()
objDataReader =
objCommand.Exec uteReader(Comma ndBehavior.Sing leRow)
If objDataReader.R ead Then
objContext.Resp onse.Write("<h2 >Product Name: </h2>")
objContext.Resp onse.Write(objD ataReader("Prod uctName"))
objContext.Resp onse.Write("<h2 >Product Price: </h2>")
objContext.Resp onse.Write(Stri ng.Format("{0,c }",
objDataReader(" UnitPrice")))
End If
objConn.Close()
Catch ex As Exception

Finally
objConn.Dispose ()
objCommand.Disp ose()
End Try
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.Is Reusable

Get
Return True
End Get
End Property

Private Function GetProductID(By Val strPath As String) As Integer 'Not
finished yet

Return 19
End Function

End Class
---------------------------------------------------------------------------------------
And this is the beginning of my web.config file:
---------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>
<appSettings>
<add key="strConn" value="server=r adu;database=wo rkdb;integrated
security=SSPI;" ></add>
</appSettings>

<system.web>
<httpHandlers >
<add verb="*" path="*"
type="ProductsH andler,Products Handler"></add>
</httpHandlers>

<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to insert debugging symbols (.pdb
information)
into the compiled page. Because this creates a larger file that
executes.....
---------------------------------------------------------------------------------------

I build the project and I see in the folder "C:\Documen ts and
Settings\Admini strator\My Documents\My
Projects\ASPNET Projects\VSNet\ ProductsHandler \bin" that there is a file
named ProductsHandler .dll. Correct. I open IIS and I check that my folder
"ASPNETProjects \VSNet\Products Handler" is really a virtual folder. It is.
The rights are there and correct, as well.

I expect to open IE and to see the product with ID=19 listed on my page.
So I type the address (it is a correct address !)

http:\\localhos t\aspnetproject s\vsnet\Product sHandler\Produc t1.aspx

and I get...

Parser Error Message: Could not load type ProductsHandler from assembly
ProductsHandler .

So the question is, please, what's wrong with my "path" in web.config ?

Thank you, Alex.


Nov 19 '05 #4

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

Similar topics

3
5264
by: Jeff Shannon | last post by:
I'm having some difficulty getting my logging configuration set correctly. I'm using a config file (copied at end of post), with the intent of setting several loggers which write to a combination of a file, stderr (for debugging), and the NT Eventlog, but I don't seem to be getting the right combination of handlers called. The desired...
1
1925
by: R. Raghuraman | last post by:
Hi, Q1: Do the section handlers in .NET work with CMAB? The CMAB seems to say so, but I am not sure. Q2: I am having trouble using CMAB with the standard section handler - I've been able to use CMAB with the HashtableSectionHandler. However, when I try to replace this with DictionarySectionHandler, I get a null reference exception: See...
4
1908
by: Nick Gilbert | last post by:
Hi, I would like the ability to store the configuration settings for all versions of my site in a single web.config file by using different sections. Eg: <siteConfig> <machine name="XENON"> <site url="/blog/"> <mode value="live">
4
2112
by: Peter Oliphant | last post by:
I've upgraded my code to VS C++.NET 2005 (Express) using /clr pure. My question is, why is there an exception to the rule in how pointer syntax is done in the event handlers? For example, why is this proper syntax: button->Click += gcnew EventHandler( this, &MyClass::MouseHandler ) ; The '&' seems like a hold over from the old syntax,...
2
2503
by: Arpan | last post by:
What exactly are configuration section handlers in a web.config file? How would you define them & what for are they used in web.config files? Is it a must for web.config files to have handlers? An example of handlers in a web.config file would be highly appreciated. Thanks, Arpan
3
1583
by: shapper | last post by:
Hello, I have been using Http handlers and I have two questions: 1. What does Property IsReusable really does and when should I use it? 2. And why should I add an httpHandler to my Web.Config? <configuration> <system.web>
2
5097
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.
31
2567
by: Scott M. | last post by:
Am I correct in thinking that because C# doesn't have the "Handles" keyword that VB .NET does, we have to register event delegates manually in C#, whereas in VB .NET using "Handles" takes care of registering the event delegate for us behind the scenes? In other words, *if* C# did have a "Handles"-type keyword, would we still need to...
1
1788
by: hb | last post by:
I have created an HTTP Handler. For simplicity of testing, it is: public class FetchItem : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { context.Response.Write("Unable to retrieve file"); context.Response.ContentType = "plain/text"; context.Response.Flush();
0
7701
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
7979
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
6284
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...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2115
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
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
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...

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.