Sir
How to retrun Json Data from ashx file
Please help me out how to implement this Quey and retrun Json Data.
<%@ WebHandler Language="C#" Class="Tracking" %>
using System;
using System.Web;
using Oracle.DataAccess.Client;
using System.IO;
using System.Data;
using Newtonsoft.Json;
public class Tracking : IHttpHandler {
operation oper = new operation();
OracleDataReader dr;
DataSet ds;
string str = "";
public void ProcessRequest (HttpContext context)
{
HttpRequest request = context.Request;
HttpResponse response = context.Response;
if (request.UrlReferrer != null )
{
string CnsNo = request.QueryString["CnsNo"].ToString().Trim();
str = "SELECT CNS.BRANCH_BRANCH_CODE,CNS.FROM_BRANCH_NAME,CNS.CNS_NO,TO_CHAR(CNS.CNS_DATE,'DD-Mon-yyyy')CNS_DATE, " +
"CNS.TOT_PKGS,CNS.CONSIGNOR_NAME,CNS.CNEE_NAME,CNS.TOT_FREIGHT,CNS.PICKUP_LOC,CNS.DELIVERY_LOC, " +
"CASE WHEN CLNDT.CLN_CHALLAN_NO IS NULL THEN 'DISPATCH PENDING' ELSE 'DISPATCH PREPARED' END DISP_STATUS, " +
"CLNDT.CLN_CHALLAN_NO,TO_CHAR(CLNDT.CLN_CHALLAN_DATE, 'DD-Mon-yyyy')CLN_CHALLAN_DATE,CLN.LORRY_REGIS_NO, " +
"CASE WHEN MR.MR_NO IS NULL THEN 'POD PENDING' ELSE 'POD RECEIVED' END POD_STATUS, " +
"MR.MR_NO POD_NO, TO_CHAR(MR.MR_DATE, 'DD-Mon-yyyy')POD_DATE, TO_CHAR(MR.ARRIVAL_DATE, 'DD-Mon-yyyy')DELIVERY_DATE " +
"FROM CT_CNS_PRINT CNS, CT_CLNDTL CLNDT ,CT_CLN CLN, CT_MR MR,CT_BILDTL BILDT, CT_LHC_PRINT LHC " +
"WHERE CNS.DIV_CODE = '1' AND CNS.DIV_CODE = CLNDT.CLN_DIV_CODE(+) AND CNS.BRANCH_BRANCH_CODE = CLNDT.CNS_BRANCH_BRANCH_CODE(+) " +
"AND CNS.CNS_NO = CLNDT.CNS_CNS_NO(+) AND CNS.CNS_DATE = CLNDT.CNS_CNS_DATE(+) " +
"AND CLNDT.CLN_DIV_CODE = CLN.DIV_CODE AND CLNDT.CLN_BRANCH_BRANCH_CODE = CLN.BRANCH_BRANCH_CODE AND CLNDT.CLN_CHALLAN_NO = CLN.CHALLAN_NO " +
"AND CLNDT.CLN_CHALLAN_DATE = CLN.CHALLAN_DATE " +
"AND CNS.DIV_CODE = MR.DIV_CODE(+) AND CNS.BRANCH_BRANCH_CODE = MR.CNS_BRANCH_BRANCH_CODE(+) AND CNS.CNS_NO = MR.CNS_CNS_NO(+) AND CNS.CNS_DATE = MR.CNS_CNS_DATE(+) " +
"AND CNS.DIV_CODE = BILDT.DIV_CODE(+) AND CNS.BRANCH_BRANCH_CODE = BILDT.CNS_BRANCH_BRANCH_CODE(+) AND CNS.CNS_NO = BILDT.CNS_CNS_NO(+) AND CNS.CNS_DATE = BILDT.CNS_CNS_DATE(+) " +
"AND CLN.DIV_CODE = LHC.DIV_CODE(+) AND CLN.LHC_BRANCH_BRANCH_CODE = LHC.BRANCH_BRANCH_CODE(+) AND CLN.LHC_LHC_NO = LHC.LHC_NO(+) AND CLN.LHC_LHC_DATE = LHC.LHC_DATE(+) " +
"AND CNS.CNS_NO='" + CnsNo.ToUpper().Trim() + "'";
dr = oper.datadisp(str);
if(dr.Read())
{
context.Response.BinaryWrite((Byte[])dr[0]);
}
else
{
}
}
}
public bool IsReusable {
get
{
return false;
}
}
}