Can gzip compression be selectively disabled in ASP.NET/IIS 7? - c#

I am using a long-lived asynchronous HTTP connection to send progress updates to a client via AJAX. When compression is enabled, the updates are not received in discrete chunks (for obvious reasons). Disabling compression (by adding a <urlCompression> element to <system.webServier>) does solve the problem:
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
However, this disables compression site-wide. I would like to preserve compression for every other controller and/or action except for this one. Is this possible? Or am I going to have to create a new site/area with its own web.config? Any suggestions welcome.
P.S. the code that does the writing to the HTTP response is:
var response = HttpContext.Response;
response.Write(s);
response.Flush();

#Aristos' answer will work for WebForms, but with his help, I've adapted a solution more inline with ASP.NET/MVC methodology.
Create a new filter to provide the gzipping functionality:
public class GzipFilter : ActionFilterAttribute
{
public override void OnActionExecuted(ActionExecutedContext filterContext)
{
base.OnActionExecuted(filterContext);
var context = filterContext.HttpContext;
if (filterContext.Exception == null &&
context.Response.Filter != null &&
!filterContext.ActionDescriptor.IsDefined(typeof(NoGzipAttribute), true))
{
string acceptEncoding = context.Request.Headers["Accept-Encoding"].ToLower();;
if (acceptEncoding.Contains("gzip"))
{
context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress);
context.Response.AppendHeader("Content-Encoding", "gzip");
}
else if (acceptEncoding.Contains("deflate"))
{
context.Response.Filter = new DeflateStream(context.Response.Filter, CompressionMode.Compress);
context.Response.AppendHeader("Content-Encoding", "deflate");
}
}
}
}
Create the NoGzip attribute:
public class NoGzipAttribute : Attribute {
}
Prevent IIS7 from gzipping using web.config:
<system.webServer>
...
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
</system.webServer>
Register your global filter in Global.asax.cs:
protected void Application_Start()
{
...
GlobalFilters.Filters.Add(new GzipFilter());
}
Finally, consume the NoGzip attribute:
public class MyController : AsyncController
{
[NoGzip]
[NoAsyncTimeout]
public void GetProgress(int id)
{
AsyncManager.OutstandingOperations.Increment();
...
}
public ActionResult GetProgressCompleted()
{
...
}
}
P.S. Once again, many thanks to #Aristos, for his helpful idea and solution.

I found a much easier way to do this. Instead of selectively doing your own compression, you can selectively disable the default IIS compression (assuming its enabled in your web.config).
Simply remove the accept-encoding encoding header on the request and IIS wont compress the page.
(global.asax.cs:)
protected void Application_BeginRequest(object sender, EventArgs e)
{
try
{
HttpContext.Current.Request.Headers["Accept-Encoding"] = "";
}
catch(Exception){}
}

What about you set the gzip compression by your self, selectivle when you wish for ? On the Application_BeginRequest check when you like to make and when you dont make compression. Here is a sample code.
protected void Application_BeginRequest(Object sender, EventArgs e)
{
string cTheFile = HttpContext.Current.Request.Path;
string sExtentionOfThisFile = System.IO.Path.GetExtension(cTheFile);
if (sExtentionOfThisFile.Equals(".aspx", StringComparison.InvariantCultureIgnoreCase))
{
string acceptEncoding = MyCurrentContent.Request.Headers["Accept-Encoding"].ToLower();;
if (acceptEncoding.Contains("deflate") || acceptEncoding == "*")
{
// defalte
HttpContext.Current.Response.Filter = new DeflateStream(prevUncompressedStream,
CompressionMode.Compress);
HttpContext.Current.Response.AppendHeader("Content-Encoding", "deflate");
} else if (acceptEncoding.Contains("gzip"))
{
// gzip
HttpContext.Current.Response.Filter = new GZipStream(prevUncompressedStream,
CompressionMode.Compress);
HttpContext.Current.Response.AppendHeader("Content-Encoding", "gzip");
}
}
}

Related

WebClient must not serve local files

I have a simple reverse proxy to avoid CORS in the browser.
In essence, it works like this:
string url = Request.QueryString["url"];
using (var webClient = new System.Net.WebClient())
{
byte[] buffer = webClient.DownloadData(url);
Response.Clear();
Response.BinaryWrite(buffer);
}
Usage:
/reverseproxy.aspx?url=http%3A%2F%2Fexample.com%2F
However, this has a vulnerability. The following request will return the logs of my IIS server.
/reverseproxy.aspx?url=c%3A%2Finetpub%2Flogs%2FLogFiles%2FW3SVC1%2Fu_ex170712.log
Is there a way to tell WebClient to not serve local files?
Without setting permissions and without using File.Exists(url)
You can create an extra assembly that creates your own implementation for a WebRequest and then configure your web.config to use your custom implementation for the file protocol.
Here is what you need:
Factory
This class decides if the reqest uri is local or not, add your own checks if needed.
public class NoLocalFile: IWebRequestCreate
{
public WebRequest Create(Uri uri)
{
// add your own extra checks here
// for example what Patrick offered in his answer
// I didn't test if I can't create a local UNC path
if (uri.IsFile && !uri.IsUnc)
{
// this is a local file request, we're going to return something safe by
// creating our own custom WebRequest
return (WebRequest) new NoLocalFileRequest();
}
else
{
// this should allow non local file request
// if needed
return FileWebRequest.Create(uri);
}
}
}
NoLocalFileRequest
This is the minimal implementation needed for our custom WebRequest
public class NoLocalFileRequest:WebRequest
{
// return an instance of our custom webResponse
public override WebResponse GetResponse()
{
return new NoLocalFileResponse();
}
}
NoLocalFileResponse
This class implements a WebResponse and returns a memorystream with the ASCII representation of the string "NO!". Here it is required to implement the ContentLength property as well.
public class NoLocalFileResponse : WebResponse {
static byte[] responseBytes = Encoding.ASCII.GetBytes("NO!");
public override long ContentLength
{
get {
return responseBytes.Length;
}
set {
// whatever
}
}
public override Stream GetResponseStream()
{
// what you want to return goes here
return new MemoryStream(responseBytes);
}
}
If you put these classes in a namespace called MyCustomWebRequests and compile this to an assembly called BlockLocalFile.dll, copy that assembly in the bin folder of your webapplication, then all you need is to make or add these changes to your web.config:
<system.net>
<webRequestModules>
<remove prefix="file:"/>
<add prefix="file:" type="MyCustomWebRequests.NoLocalFile, BlockLocalFile"/>
</webRequestModules>
</system.net>
When you testdrive this you should find that your previous code still works unchanged while the browsers that try the local file trick will get "NO!" returned instead of your file content.
Be aware that this config change applies to all code that runs in the appdomain of that webapplication. If you have legit code that also does require the normal use of the file protocol you have to make changes to the factory method that decides which WebRequest to create.
You could check if your provided URI is an URL or a file reference using the Uri class. You could use the code found here:
private static bool IsLocalPath(string p)
{
return new Uri(p).IsFile;
}
Even safer would be to check the scheme of the Uri to match to http or https:
private static bool IsHttpOrHttps(string uri)
{
Uri u = new Uri(uri);
return u.Scheme == Uri.UriSchemeHttp || u.Scheme == Uri.UriSchemeHttps;
}

Web API and HTTP Module

We have an HTTP Module that decodes all encoded requests.
It works great with all WCF requests, but NOT in Web Api requests- in Web Api the request (both POST and GET) gets to the service still encoded
I see that it Hits the HTTP Module but,again,still gets to the service encoded.
How can i fix it? or what am i doing wrong?
i know that its better to work with Message Handlers in Web Api, but HTTP Modules suppose to work too- no?
HTTP Module:
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
context.EndRequest += context_PreSendRequestContent;
}
void context_PreSendRequestContent(object sender, EventArgs e)
{
string encodedQuerystring = HttpContext.Current.Request.QueryString.ToString();
if (!string.IsNullOrEmpty(encodedQuerystring))
{
System.Collections.Specialized.NameValueCollection col = new System.Collections.Specialized.NameValueCollection();
col.Add("q", encodedQuerystring);
WebFunction.CreateQuerystring(HttpContext.Current, col);
}
}
void context_BeginRequest(object sender, EventArgs e)
{
string encodedQueryString = String.Empty;
if (HttpContext.Current.Request.QueryString.Count > 0 && HttpContext.Current.Request.QueryString["q"] != null)
{
object _p = HttpContext.Current.Request.QueryString;
encodedQueryString = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request.QueryString["q"].ToString());
string originalQueryString = HttpContext.Current.Server.UrlDecode(WebFunction.Base64Decode(encodedQueryString));
if (!string.IsNullOrEmpty(originalQueryString))
{
WebFunction.CreateQuerystring(HttpContext.Current, WebFunction.ConvertQueryToCollection(originalQueryString));
}
}
}
WebFunction:
public static void CreateQuerystring(HttpContext context, System.Collections.Specialized.NameValueCollection nameValueCollection)
{
// reflect to readonly property
PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);
// make collection editable
isreadonly.SetValue(context.Request.QueryString, false, null);
context.Request.QueryString.Clear();
context.Request.QueryString.Add(nameValueCollection);
// make collection readonly again
isreadonly.SetValue(context.Request.QueryString, true, null);
}
Web Api:
public class NamesController : ApiController
{
[HttpGet]
[ActionName("GET_NAMES")]
public Drugs_ResponseData Get(string q)
{
//need to add the decode function to get it to work
string[] arrAmpersant = Commonnn.DecodeFrom64(q).Split('&');
Names_obj = new Names();
return _obj.GetResult(Convert.ToInt32(Commonnn.GetValFromEqual(arrAmpersant[0])));
}
}
It seems that the Web API doesn't use the QueryString collection in the request, but it parses the URL itself.
See the GetQueryNameValuePairs method in this file - they take the Uri and parse its Query property.
So you have two options to do that:
The dirty one is to change the Uri of the request in your the HTTP module. I don't know whether it's possible, but some reflection could do the trick.
The nicer way would be to use the Web API message handler.
May I suggest you use Context.Items and let the QueryString have the encoded version.
It's a not very well known built in key/value dictionary which last throughout a request where you easily store any object and then share it between module, handlers, etc.
Using this would very like give you a better performance than unlocking the QueryString object, but more importantly, you process the value in one place and reuse it in many, and when needed, you just add a second value, the complete QueryString collection or any other value you want to share across a request.
void context_BeginRequest(object sender, EventArgs e)
{
string encodedQueryString = String.Empty;
if (HttpContext.Current.Request.QueryString.Count > 0 && HttpContext.Current.Request.QueryString["q"] != null)
{
string encodedQueryString = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request.QueryString["q"].ToString());
HttpContext.Current.Items("qs_d") = HttpContext.Current.Server.UrlDecode(WebFunction.Base64Decode(encodedQueryString));
}
}
Web Api:
public class NamesController : ApiController
{
[HttpGet]
[ActionName("GET_NAMES")]
public Drugs_ResponseData Get(string q)
{
string[] arrAmpersant = Commonnn.DecodeFrom64(HttpContext.Current.Items("qs_d").ToString()).Split('&');
Names_obj = new Names();
return _obj.GetResult(Convert.ToInt32(Commonnn.GetValFromEqual(arrAmpersant[0])));
}
}
Side note: I see you call HttpContext.Current.Server.UrlDecode twice. I don't think you need that unless your Base64Decode method encode the value again.
You can handle like this
protected void Application_BeginRequest(object sender, EventArgs e)
{
var app = (HttpApplication)sender;
string path = app.Context.Request.Url.PathAndQuery;
int pos = path.IndexOf("?");
if (pos > -1)
{
string[] array = path.Split('?');
app.Context.RewritePath(array[0]+"?"+ HttpContext.Current.Server.UrlDecode(array[1]));
}
}
Adding on to #Tomáš Herceg 's answer, I would implement a Web Api message handler rather than modifying your HttpModule to accommodate Web Api.
public class DecodeQueryStringMessageHandler : DelegatingHandler
{
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request,
CancellationToken cancellationToken)
{
if (request.Method == HttpMethod.Get)
{
var originalQueryString = request.RequestUri.Query;
if (!string.IsNullOrEmpty(originalQueryString))
{
var ub = new UriBuilder(request.RequestUri) { Query = HttpUtility.UrlDecode(originalQueryString) };
request.RequestUri = ub.Uri;
}
}
return base.SendAsync(request, cancellationToken);
}
}
It is possible, but you will need reflection, what means that exist a risk here. Please, let me suggest you what I consider to be a more clean solution after the solution.
Solution
if (!string.IsNullOrEmpty(originalQueryString))
{
var request = HttpContext.Current.Request;
request.GetType().InvokeMember("QueryStringText", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty, null, request, new[] { "q=" + originalQueryString });
//WebFunction.CreateQuerystring(HttpContext.Current, WebFunction.ConvertQueryToCollection(originalQueryString));
}
This will update the following properties of the Request:
Request.Param
Request.QueryString
Request.ServerVariables
Request.Url
but will not update the:
Request.RawUrl
Cleaner Solution
IIS URL Rewrite Module
http://www.iis.net/learn/extensions/url-rewrite-module/developing-a-custom-rewrite-provider-for-url-rewrite-module

HTTP Post using .Net C# in speedway connect software

I am using RFID Speedway connect software in the Speedway reader, I got a PHP sample for HTTP Post and after googled sometime I couldn't find the sample for .Net C#. So I tried in simple asp.net application[hosted in IIS] to receive the HTTP post response from the reader but I never get in to it.
Below is my sample code.
URL assigned in the reader is http://MY_IP/Default.aspx
My asp.net code sample is :
protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder displayValues = new System.Text.StringBuilder();
System.Collections.Specialized.NameValueCollection postedValues = Request.Form;
Label1.Text = postedValues.AllKeys.Length.ToString();
}
my page never got hit. Can anyone tell me how to achieve the HTTP Post response in C#.
Thanks
Try using a generic handler
myHandler.ashx
public class myHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string requestStr= new StreamReader(context.Request.InputStream).ReadToEnd();
context.Response.ContentType = "application/text";
switch (context.Request.HttpMethod)
{
case "GET":
break;
case "POST":
context.Response.Write("ok");
break;
default:
break;
}
}
public bool IsReusable
{
get { return false; }
}
}

How to access session in aspx that was modified in ashx?

I am using uploadify to upload files, they automatically post to the handler. I then modify the session in the handler that I have setup as a static property in a common class of the website. I then try to access that same session in the aspx page, and the value is null. I have a feeling this is because of cookies, but there needs to be a way to work around this without exposing the sessionid in the url.
ASHX:
public class Upload : IHttpHandler, IReadOnlySessionState, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
...
CMSSession.Current.UploadedFiles.Add(fileName);
}
}
Session Class:
public class CMSSession
{
public static CMSSession Current
{
get
{
CMSSession session = (CMSSession)HttpContext.Current.Session["__CMSSession__"];
if (session == null)
{
session = new CMSSession();
HttpContext.Current.Session["__CMSSession__"] = session;
}
return session;
}
}
public List<string> UploadedFiles { get; set; }
}
ASPX:
if (CMSSession.Current.UploadedFiles != null)
{
...
}
else
{
IT'S ALWAYS NULL
}
Web.Config:
<sessionState mode="InProc" cookieless="false" /> - causes session to always null in aspx when modified in ashx
<sessionState mode="InProc" cookieless="true" /> - session value is not null, but sessionid is exposed in the url
How do I access & modify the current session within the ASHX file WITHOUT changing cookieless to true and then access the session from the ASPX page?
I have tried using HttpContext and using the context passed into the ASHX...nothing works.
same as this question, but there has to be a more secure way: session set in ashx and get that session on aspx
Any ideas?
I found the answer: When the handler is being called from FLASH (like swfupload or uploadify) it does not pass the current sessionid to the handler. The handler then creates a NEW session. To fix this, do the following:
Your UI: JavaScript:
$(Selector).uploadify({
swf: 'uploadify.swf',
uploader: 'Upload.ashx?ASPSESSID=<%=Session.SessionID%>'
});
Add to: Global.asax:
void Application_BeginRequest(object sender, EventArgs e)
{
try
{
string session_param_name = "ASPSESSID";
string session_cookie_name = "ASP.NET_SESSIONID";
string session_value = Request.Form[session_param_name] ?? Request.QueryString[session_param_name];
if (session_value != null) { UpdateCookie(session_cookie_name, session_value); }
}
catch (Exception) { }
}
void UpdateCookie(string cookie_name, string cookie_value)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(cookie_name);
if (cookie == null)
{
HttpCookie cookie1 = new HttpCookie(cookie_name, cookie_value);
Response.Cookies.Add(cookie1);
}
else
{
cookie.Value = cookie_value;
HttpContext.Current.Request.Cookies.Set(cookie);
}
}
Taken & simplified for uploadify from:
http://snipplr.com/view/15180/
You may need to use an authid if using formsauthentication:
&AUTHID=<%= Request.Cookies[FormsAuthentication.FormsCookieName] == null ? "" : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>
append that to the uploader parameter in the jQuery.
Then add the following to the global:
try
{
string auth_param_name = "AUTHID";
string auth_cookie_name = FormsAuthentication.FormsCookieName;
string auth_value = Request.Form[auth_param_name] ?? Request.QueryString[auth_param_name];
if (auth_value != null) { UpdateCookie(auth_cookie_name, auth_value); }
}
catch (Exception) { }
You can now access the same session from the handler (even using the static session object I used above in the question) in IE, Chrome, FF, ect.
Context.Session is null.. because connection to HttpHandler has another Context.Session
(debug and try: Context.Session.SessionId in where is the fileInput is different from Context.Session.SessionId in Upload.ashx)!
I suggest a workaround: pass a reference to the elements you need in the second session ( in my sample i pass the original SessionId using sessionId variable)
....
var sessionId = "<%=Context.Session.SessionID%>";
var theString = "other param,if needed";
$(document).ready(function () {
$('#fileInput').uploadify({
'uploader': '<%=ResolveUrl("~/uploadify/uploadify.swf")%>',
'script': '<%=ResolveUrl("~/Upload.ashx")%>',
'scriptData': { 'sessionId': sessionId, 'foo': theString },
'cancelImg': '<%=ResolveUrl("~/uploadify/cancel.png")%>',
....
and use this items in .ashx file.
public void ProcessRequest(HttpContext context)
{
try
{
HttpPostedFile file = context.Request.Files["Filedata"];
string sessionId = context.Request["sessionId"].ToString();
....
If you need to share complex elements use Context.Application instead of Context.Session, using original SessionID: Context.Application["SharedElement"+SessionID]

Getting form data from HttpListenerRequest

I have a HttpListenerRequest which was initiated from a html <form> that was posted. I need to know how to get the posted form values + the uploaded files. Does anyone know of an example to save me the time doing it for myself? I've had a google around but not found anything of use.
The main thing to understand is that HttpListener is a low level tool to work with http requests. All post data is in HttpListenerRequest.InputStream stream. Suppose we have a form like that:
<form method=\"post\" enctype=\"multipart/form-data\"><input id=\"fileUp\" name=\"fileUpload\" type=\"file\" /><input type=\"submit\" /></form>
Now we want to see the post data. Lets implement a method to do this:
public static string GetRequestPostData(HttpListenerRequest request)
{
if (!request.HasEntityBody)
{
return null;
}
using (System.IO.Stream body = request.InputStream) // here we have data
{
using (var reader = new System.IO.StreamReader(body, request.ContentEncoding))
{
return reader.ReadToEnd();
}
}
}
upload some file and see result:
Content-Disposition: form-data; name="somename"; filename="D:\Test.bmp"
Content-Type: image/bmp
...here is the raw file data...
Next suppose we have simple form without uploading files:
<form method=\"post\">First name: <input type=\"text\" name=\"firstname\" /><br />Last name: <input type=\"text\" name=\"lastname\" /><input type=\"submit\" value=\"Submit\" /></form>
Let's see the output:
firstname=MyName&lastname=MyLastName
Combined form result:
Content-Disposition: form-data; name="firstname"
My Name
Content-Disposition: form-data; name="somename"; filename="D:\test.xls"
Content-Type: application/octet-stream
...raw file data...
As you can see in case of simple form you can just read InputStream to string and parse post values. If there is a more complex form - you need to perform more complex parsing but it's still can be done. Hope this examples will save your time. Note, that is not always the case to read all stream as a string.
Odd that an accepted answer with full source code + a link to download
a working demo would result in a negative score and votes to be
deleted. If I were the kind of person who cared about my score I'd
have deleted this answer, and then nobody would have benefited.
Psychology, eh :)
I found a few examples of web servers for MonoTouch but none of them parsed the data sent in a POST request. I looked around the web and was unable to find any examples of how to achieve this. So now that I’ve written it myself I’ve decided to share my own implementation. This includes not only the code for processing the form post data but also for registering request handlers etc.
Here is an example of how you would use the web server
public BookUploadViewController()
: base("BookUploadViewController", null)
{
RequestHandler = new DefaultRequestHandler();
var defaultActionHandlerFactory = new DefaultActionHandlerFactory();
RegisterActionHandlers(defaultActionHandlerFactory);
RequestHandler.AddActionHandlerFactory(defaultActionHandlerFactory);
WebServer = new EmbeddedWebServer(RequestHandler);
}
void RegisterActionHandlers(DefaultActionHandlerFactory factory)
{
factory.RegisterHandler(
request => request.RawUrl == "/",
request => new IndexActionHandler(request)
);
factory.RegisterHandler(
request =>
string.Compare(request.RawUrl, "/Upload", true) == 0 &&
string.Compare(request.HttpMethod, "POST", true) == 0,
request => new UploadActionHandler(request)
);
}
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
StatusLabel.Text = string.Format("Server listening on\r\nhttp://{0}:8080", GetIPAddress ());
WebServer.Start(8080);
}
public override void ViewDidDisappear (bool animated)
{
base.ViewDidDisappear(animated);
WebServer.Stop();
}
And here are two app specific examples of request handlers
class IndexActionHandler : DefaultActionHandler
{
public IndexActionHandler(HttpListenerRequest request)
: base(request)
{
}
public override ActionResult Execute()
{
var result = new HtmlResult();
result.AppendLine("<html>");
result.AppendLine("<body>");
result.AppendLine("<h1>Upload an image</h1>");
result.AppendLine("<form action='/Upload' enctype='multipart/form-data' method='post'>");
result.AppendLine ("<input name='Image' type='file'/><br/>");
result.AppendLine("<input name='Upload' type='submit' text='Upload'/>");
result.AppendLine("</form>");
result.AppendLine("</body>");
result.AppendLine("</html>");
return result;
}
}
class UploadActionHandler : DefaultActionHandler
{
public UploadActionHandler(HttpListenerRequest request)
: base(request)
{
}
public override ActionResult Execute()
{
string errorMessage = null;
var file = FormData.GetFile("Image");
if (file == null
|| file.FileData == null
|| file.FileData.Length == 0
|| string.IsNullOrEmpty(file.FileName))
errorMessage = "No image uploaded";
if (errorMessage == null)
ProcessFile(file);
var result = new HtmlResult();
result.AppendLine("<html>");
result.AppendLine("<body>");
if (errorMessage == null)
result.AppendLine("<h1>File uploaded successfully</h1>");
else
{
result.AppendLine("<h1>Error</h1>");
result.AppendLine("<h2>" + errorMessage + "</h2>");
}
result.AppendLine("</body>");
result.AppendLine("</html>");
return result;
}
void ProcessFile(MultiPartStreamFileValue postedFile)
{
string fileName = "Where to save the file";
using (var fileStream =
new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
fileStream.Write(postedFile.FileData, 0, postedFile.FileData.Length);
}
}
}
You can download the source code here https://sites.google.com/site/mrpmorris/EmbeddedWebServerMT.zip
It's an old thread but I think the demand still applies. In newer versions of .Net (tested on net6.0) it is possible to avoid manual parsing of application/x-www-form-urlencoded content using the standard function System.Web.HttpUtility.ParseQueryString(string content).
One still needs to manually read the content as text from the request input stream, as shown in the accepted answer above.

Categories

Resources