We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Class Not Executing

Medium Priority
269 Views
Last Modified: 2013-12-16
Hi,

I have an event handler and it mostly works, but I added an insert calling to a class file.
the line does not execute, nor does it throw an error.

at this line
    //Add user
            Dal.InsertUser(8);
line: 24

if anyone know what I am doing wrong, would greatly appreciate it

below is the full code of the handler

<%@ WebHandler Language="C#" Class="AdHandler" %>

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

// Context = HttpContext.Current;

public class AdHandler : IHttpHandler
{
    DAL Dal = new DAL();
    public void ProcessRequest(HttpContext context)
    {

        string url = context.Request.QueryString["AdUrl"];

        try
        {


            //Add user
            Dal.InsertUser(8);
            
            //Add Hit
            AddHit(url);
            
           

        }

        catch
        {

        }

        finally
        {

            context.Response.Redirect(url);

        }

    }

    public int AddHit(string url)
    {

        SqlConnection con = new
SqlConnection(WebConfigurationManager.ConnectionStrings["SQLDbconn"].ConnectionString);

        con.Open();

        SqlCommand com = new SqlCommand("AddHit", con);

        com.CommandType = System.Data.CommandType.StoredProcedure;

        com.Parameters.Add(new SqlParameter("@url", url));

        int res = com.ExecuteNonQuery();

        con.Close();

        return res;

    }

    public bool IsReusable
    {

        get
        {

            return false;

        }

    }

}

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
LOL... ok,,, I'm not blond. but somedays, I don't know.

I can't believe I just did that

Author

Commented:
ok,, it's thowing an error with


context.session("")

I think I need to add something like

IRequiresSessionState  I'm not a C programmer but I think I had a similar problem before
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.