.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

A simple HTTP echo server

Posted By:papsantony       Posted Date: August 13, 2010    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  

A simple HTTP echo server

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Net.Mail;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Xml;

public class MainClass
    public static void Main()
        using (HttpListener listener = new HttpListener())
            listener.AuthenticationSchemes = AuthenticationSchemes.Negotiate;

            HttpListenerContext ctx = listener.GetContext();
            ctx.Response.StatusCode = 200
            string name = ctx.Request.QueryString["name"];

            StreamWriter writer = new StreamWriter(ctx.Response.OutputStream);

Hello, {0}

, name);
                foreach (string header in ctx.Request.Headers.Keys)
  • {0}: {1}
  • "
    ,header, ctx.Request.Headers[header]);



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend