I want to code a c# Http webserver. If the URL is requested I want to send the HTML page with CSS and JS to the client. How can I do that?
static void Main(string[] args)
{
HttpListener server = new HttpListener(); // this is the http server
//server.Prefixes.Add("http://127.0.0.1/"); //we set a listening address here (localhost)
server.Prefixes.Add("http://localhost:2002/");
server.Start(); // and start the server
Console.WriteLine("Server started...");
while (true)
{
HttpListenerContext context = server.GetContext();
HttpListenerResponse response = context.Response;
byte[] buffer = Encoding.UTF8.GetBytes("<html></html>");
response.ContentLength64 = buffer.Length;
Stream st = response.OutputStream;
st.Write(buffer, 0, buffer.Length);
context.Response.Close();
}
}
I want to send the full HTML CSS JS website to the client.
sry for my bad english.