Top Ad unit 728 × 90


http handler example using

how to generate random password in c#
All the request of is managed by a specialized component known as an HTTP handler. Now as a web developer ,we might want to have some of our own feature plugged in. we want to handle some knew kind of requests or perhaps we want to handle an existing request ourselves to have more control on the generated response.

Example : we may want to decide how to request for .jpg or .gif files will be handles. we need HTTPHandler to have our feature in place..

Tags |  asp handler,asp net web forms examples,asp net mvc project examples,asp c# examples,asp website examples,html in aspclassic asp example

For more details about handler you can take reference of MSDN.


Go for  Client side Multiple parameter post :


A handler is responsible for fulfilling requests from a browser. Requests that a browser manages are either handled by file extension or by calling the handler directly.

To create your first table below, complete the following steps:

Step 1 . 

create database Test

create table employee


Id int identity,

name nvarchar(100)


insert into Employee 
values ('vikas')
insert into Employee 
values ('mohan')
insert into Employee 
values ('ramesh')
insert into Employee 
values ('rahul')
insert into Employee 
values ('rakesh')

Step 2 :
To create your own HTTP handler, complete the following steps


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Script.Serialization;

namespace HttpHandler

    /// Summary description for randomqueryfromsql
    public class randomqueryfromsql : IHttpHandler

        public void ProcessRequest(HttpContext context)
           int employeeId = 0;
            int.TryParse(context.Request.QueryString["employeeId"], out employeeId);
            string json = this.GetEmployeeJSON(employeeId);
            context.Response.ContentType = "text/json";
        private string GetEmployeeJSON(int EmployeeId)
            List employee = new List();
            using (SqlConnection conn = new SqlConnection())
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
                using (SqlCommand cmd = new SqlCommand())
                    cmd.CommandText = "SELECT * FROM employee WHERE Id = @Id OR @Id= 0";
                    cmd.Parameters.AddWithValue("@Id", EmployeeId);
                    cmd.Connection = conn;
                    using (SqlDataReader sdr = cmd.ExecuteReader())
                        while (sdr.Read())
                                CustomerId = sdr["id"],
                                Name = sdr["Name"]
                return (new JavaScriptSerializer().Serialize(employee));
        public bool IsReusable
                return false;

Step 3:
add below code in web.config for connection.


Step 4 : finally out put will display in below window.

html in aspclassic asp example

Conclusion : we can use http handler for lots of work,where we want to eliminate the Page life cycle.
if we not use page lifecycle, then using http handler we can provide more performance of application.
http handler example using Reviewed by Vikas Kumar Singh on December 12, 2017 Rating: 5


All Rights Reserved by © 2018

Contact Form


Email *

Message *

© 2018 All rights reserved by DotNetBasic. Powered by Blogger.