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. 3 1947
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.
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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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">
|
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,...
|
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
| |
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>
|
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.
|
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...
|
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();
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |