Click here to Skip to main content
15,891,851 members
Articles / Programming Languages / C#

C# WebServer Using Sockets

Rate me:
Please Sign up or sign in to vote.
5.00/5 (27 votes)
23 Jan 2014CPOL7 min read 103.8K   9.9K   161  
How to make a simple web server which supports GZIP compression, applications, and sessions.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script type="text/javascript" src="Script/Ajax.js"></script>
    <link rel="stylesheet" href="chat.css" type="text/css" />
    <title>Chat Login Page</title>
</head>
<body style="background:url('background.jpg');">
    <script type="text/javascript">

        function Loggedon_Response(response, action) {

            var chatmessage = eval('(' + response + ')');
            switch (chatmessage.MessageCode) {
                case 0:
                    alert(chatmessage.Value);
                    break;
                case 1:
                    eval('(' + chatmessage.Value + ')');
                    break;
            }
        }

        function SendLoginRequest(username, password) {
            if (username.toString() == "") {
                alert("Username field is empty");
                return;
            }
            if (password.toString() == "") {
                alert("Password field is empty");
                return;
            }
            ajax.SendRequest(Loggedon_Response, window.location.href + "?op=login&username=" + username + "&password=" + password, true);

        }

           

           
    </script>
    <script type="text/javascript">

        function GetUserName() {
            return document.getElementById("txtUsername").value;
        };

        function GetPassword() {
            return document.getElementById("txtPassword").value;
        };


        function btnLogin_Click() {
            SendLoginRequest(GetUserName(), GetPassword());
        };



    </script>
    <span>Login page. </span>
    <div>
        <span>
            Username:</span>
        <input id="txtUsername" type="text" />
        <span>
            Password:</span>
        <input id="txtPassword" type="text" />
        <input id="btnLogin" type="button" value="login"  onclick="javascript:btnLogin_Click()" style="width:100px;" />
    
    </div>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United Kingdom United Kingdom
Alberto Biafelli,
Software Developer

Comments and Discussions