locked
Help with custom HttpHandlers RRS feed

  • Question

  • User2033852712 posted

    Hello -

     

    I'm new ASP.NET and trying to write a custom HTTP handler that can be invoked from a asp page. I'm using ASP Web Matrix as my IDE.

    Here is how my .ashx file looks like

    <%@ WebHandler language="VJ#" class="Demo.ShowLogin" %>

    package Demo;

    import System.*;
    import System.Web.*;

    public class ShowLogin implements IHttpHandler {

        public void ProcessRequest(HttpContext context) {
            // TODO: Write request handling code here
            // TODO: Write request handling code here
          context.Server.Transfer("ui/Welcome.aspx");
        }

        public boolean get_IsReusable() {
            return true;
        }
    }

    Here is how my web.config file looks like

    <?xml version="1.0" encoding="UTF-8" ?>

    <configuration>

             <appSettings>
                <add key="database" value="sqlserver"/>
             </appSettings>

        <system.web>

           <httpHandlers>
            <add
             verb="*"
             path="*.aspx"
             type="System.Web.UI.PageHandlerFactory" />
            <add
             verb="*"
             path="/ui/*.aspx"
             type="Demo.ShowLogin, Demo" />
           </httpHandlers>

        </system.web>

    </configuration>

    The issue i'm running into is - there is no .dll file generated for .ashx file. How do i compile my .ashx file and keep that under the /bin directory.

    I get the below error every time I try to run my app

    Configuration Error

    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: File or assembly name Login, or one of its dependencies, was not found.

    Source Error:

    Line 11:        <httpHandlers>
    Line 12:         <add
    Line 13:          verb="*"
    Line 14:          path="*.aspx"
    Line 15:          type="System.Web.UI.PageHandlerFactory" />

    Source File: C:\WEM\ASP\good\web.config    Line: 13

    Assembly Load Trace: The following information can be helpful to determine why the assembly 'Login' could not be loaded.

    Any help?

     

    Thanks in advance.

    Wednesday, April 20, 2005 3:11 AM

All replies

  • User-886813230 posted

    If I'm not mistaken, you're mixing modes.  If you're using the ASHX file, then you don't use the web.config to set it up.  Instead you just invoke the .ashx file directly.  The web.config changes that you make would be used if you had created a regular assemply containing the class that you have defined.

    Hope that helps.

    Wednesday, April 20, 2005 4:40 PM