locked
HTTP handlers WEB.CONFIG syntax, please ! RRS feed

  • Question

  • User-162287177 posted
    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.ProcessRequest and IHttpHandler.IsReusable). Anyway, here it is: --------------------------------------------------------------------------------------- Imports System.Data.SqlClient Imports System.Web Imports System.Data Public Class ProductsHandler Implements IHttpHandler Public Sub ProcessRequest(ByVal objContext As HttpContext) Implements IHttpHandler.ProcessRequest Dim intProductID As Integer Dim objConn As New SqlConnection() Dim objCommand As SqlCommand Dim objDataReader As SqlDataReader Dim strSelect As String Try intProductID = GetProductID(objContext.Request.Path) strSelect = "Select ProductName, UnitPrice from Products where ProductID=@ProductID" objCommand = New SqlCommand(strSelect, objConn) objCommand.Parameters.Add("@ProductID", intProductID) objConn.ConnectionString = ConfigurationSettings.AppSettings("strConn") objConn.Open() objDataReader = objCommand.ExecuteReader(CommandBehavior.SingleRow) If objDataReader.Read Then objContext.Response.Write("

    Product Name:

    ") objContext.Response.Write(objDataReader("ProductName")) objContext.Response.Write("

    Product Price:

    ") objContext.Response.Write(String.Format("{0,c}", objDataReader("UnitPrice"))) End If objConn.Close() Catch ex As Exception Finally objConn.Dispose() objCommand.Dispose() End Try End Sub Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable Get Return True End Get End Property Private Function GetProductID(ByVal 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" ?> <configuration> <appSettings> <add key="strConn" value="server=radu;database=workdb;integrated security=SSPI;"></add> </appSettings> <system.web> <httpHandlers> <add verb="*" path="*" type="ProductsHandler,ProductsHandler"></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:\Documents and Settings\Administrator\My Documents\My Projects\ASPNETProjects\VSNet\ProductsHandler\bin" that there is a file named ProductsHandler.dll. Correct. I open IIS and I check that my folder "ASPNETProjects\VSNet\ProductsHandler" is indeed a virtual folder. It is. The rights are there and they are 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://localhost/aspnetprojects/vsnet/ProductsHandler/Product1.aspx and I get... Configuration error: 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 ? I have also tried path="product*.aspx", with the same result. Thank you, Alex.
    Tuesday, February 1, 2005 7:45 PM

All replies

  • User-162287177 posted
    Thank you - this problem is solved. Alex
    Tuesday, February 1, 2005 10:02 PM