Response that is sent back to the web browser / client.
Namespace:
HttpServerAssembly: HttpServer (in HttpServer.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
| C# |
|---|
public class HttpResponse : IHttpResponse |
| Visual Basic (Declaration) |
|---|
Public Class HttpResponse _ Implements IHttpResponse |
| Visual C++ |
|---|
public ref class HttpResponse : IHttpResponse |
Remarks
A response can be sent if different ways. The easiest one is to just fill the Body stream with content, everything else will then be taken care of by the framework. The default content-type is text/html, you should change it if you send anything else.
The second and slightly more complex way is to send the response as parts. Start with sending the header using the SendHeaders method and then you can send the body using SendBody method, but do not forget to set ContentType and ContentLength before doing so.
Examples
// Example using response body. class MyModule : HttpModule { public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session) { StreamWriter writer = new StreamWriter(response.Body); writer.WriteLine("Hello dear World!"); writer.Flush(); // return true to tell webserver that we've handled the url return true; } }