[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

Class Not Executing

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

0
TheWebGuy38
Asked:
TheWebGuy38
  • 2
  • 2
2 Solutions
 
käµfm³d 👽Commented:
You wouldn't know if it were throwing an error since you are swallowing the exception with an empty catch statement. Aside from that, we probably won't be able to help you without seeing the definition of InsertUser.
0
 
TheWebGuy38Author Commented:
LOL... ok,,, I'm not blond. but somedays, I don't know.

I can't believe I just did that
0
 
TheWebGuy38Author 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
0
 
käµfm³d 👽Commented:
C# is case-sensitive. Try:

    context.Session["some_key"]
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now