Software & Finance

ASP.NET - Create a simple web handler (.ashx) file

You can create a generic handler by pressing Ctrl + N and select the Generic Handler under C# and web section:



The C# code for welcomehandler is given below:

using System;
using System.Web;

public class WelcomeHandler : IHttpHandler {
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
       string username = context.Request["username"];
       string password = context.Request["password"];

       if (username == null || password == null)
          context.Response.Write("Hey, you have not submitted your username or password. Please try again!");
          context.Response.Write("Hey " + username + "! Your password is: " + password);
    public bool IsReusable {
        get {
            return false;

Refer to the following links on how it appears on the web: