HttpHandler Object- to Determine the JQuery Calling Source Page
<p>I have HTTP Handler FaqsJson.ashx which is creating a JSON utilizing the StringBuilder.<br>
In this Handler Object I am calling a StoredProceedure and Im passing a single Variable FactTypeID.  For now this FactTypeID is hard-coded.</p>

<p>From within this Handler Object I need help to be able to iterate through some other Object or Server Variable
in order to determine the Source Page which called the Object.<br>
Also, I need to be able to call this HttpHandler from the JQuery Functions of several .aspx Pages:<br>
Im not clear how to check from which JQuery Source Page this Handler Object was called.<br>
I would appreciate any help as Im completely unfamiliar with HttpHandler Object.</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;

namespace DaVincisApp1
{
/// &lt;summary&gt;
/// Summary description for FaqsJson
/// &lt;/summary&gt;
public class FaqsJson : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        Int32 FactTypeID = 6;
        string query = "dav_getFactsByFactType " + FactTypeID;

        string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
        SqlConnection myConnection = new SqlConnection(connectionString);
        SqlCommand myCommand = new SqlCommand(query, myConnection);
        try
        {
            myConnection.Open();
            SqlDataReader reader = myCommand.ExecuteReader();
            StringBuilder strFaqs = new StringBuilder();
            int start = 0;
            strFaqs.Append("[");
            while (reader.Read())
            {
                if (start == 0)
                    strFaqs.Append("{");
                else
                    strFaqs.Append(",{");

                strFaqs.Append(string.Format("\"Question\":\"{0}\",", reader[0].ToString()));
                strFaqs.Append(string.Format("\"Answer\":\"{0}\"", reader[1].ToString()));
                strFaqs.Append("}");
                start++;
            }
            strFaqs.Append("]");

            context.Response.ContentType = "application/json";
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.Write(strFaqs.ToString());
            context.Response.End();

            reader.Close();
            myCommand.Dispose();
            myConnection.Close();
        }
        catch (Exception ex)
        {
            string exception = ex.Message;
            // Logg the exception here
        }
        finally
        {
            myConnection.Close();
            myCommand.Dispose();
        }
    }
    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}
}
</code></pre>

<p>Here is one of my Source Pages PaintFaqs.aspx which should pass a Parameter = 1 to the Handler<br>
Another Source Page Glossary.aspx should pass a Parameter = 6.<br>
I would then check that Parameter within the Handler Object to set FactTypeID</p>

<pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true"
CodeBehind="PaintFaqs.aspx.cs" Inherits="DaVincisApp1.PaintFaqs" %&gt;

&lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"&gt;
&lt;/asp:Content&gt;
&lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
&lt;script type="text/javascript"&gt;
    function ToggleFAQ(title) {
        //$("#" + title).toggle("slow");

        Aobj = document.getElementById(title);
        DIVobj = document.getElementById(title + "-link-div");
        LINKobj = document.getElementById(title + "-link-a");

        current_state = Aobj.style.display;

        if (current_state != "inline") {
            Aobj.style.display = "inline";
            Aobj.style.visibility = "visible";
            DIVobj.className = "question-clicked";
            LINKobj.className = "questionLink-clicked";
        }
        else {
            Aobj.style.display = "none";
            Aobj.style.visibility = "hidden";
            DIVobj.className = "faqquestion";
            LINKobj.className = "questionLink";
        }
    }

    $(document).ready(function () {
        $.getJSON('FaqsJson.ashx', function (datas) {
            var str = "";
            var index = 1;
            $.each(datas, function () {
                str += "&lt;div id=\"A" + index + "-link-div\" class=\"faqquestion\"&gt;" +
                            "&lt;a id=\"A" + index + "-link-a\" href=\"javascript://\" class=\"questionLink\" onclick=\"ToggleFAQ('A" + index + "');\"&gt;" +
                            this['Question'] +
                            "&lt;/a&gt;" +
                       "&lt;/div&gt;";
                str += "&lt;div id=\"A" + index + "\" style=\"display: none;\"&gt; " +
                            "&lt;div class=\"faqanswer\"&gt;" +
                                "&lt;div class=\"answerbox\"&gt;" +
                                    this['Answer'] +
                                "&lt;/div&gt;" +
                            "&lt;/div&gt;" +
                        "&lt;/div&gt;";
                index++;
            });
            $("#mid-featureleft-client .controlbox").html(str);
        });
    });
&lt;/script&gt;
&lt;div id="top-feature-client"&gt;
    &lt;div class="contentheader"&gt;
        &lt;img alt="image1" src="images/Facts/FaqHeader2.png" style="height: 245px; width: 848px" /&gt;
    &lt;/div&gt;
    &lt;div style="clear: both;"&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;div id="mid-feature-client"&gt;
    &lt;div id="mid-featureleft-client"&gt;
        &lt;div class="contentheader"&gt;
            &lt;h1&gt;
                General Painting Facts&lt;/h1&gt;
            &lt;img height="16px" width="552px" src="Images/Columns/hr_red1.png" alt="" /&gt;
        &lt;/div&gt;
        &lt;div class="controlbox"&gt;
            &lt;br /&gt;
        &lt;/div&gt;
        &lt;div style="clear: both;"&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div style="clear: both;"&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p></p>
