我想在C#控制台应用程序中解析HTTP POST请求方面的一些帮助.该应用程序使用Owin运行"网络服务器".此处提供了该应用程序的详细信息,相关代码的当前"稳定版本"在此处.
我正在扩展上述应用程序以通过Web UI启用配置.例如,app当前报告了大量参数.我希望最终用户能够选择通过网络报告哪些参数.为此,我对上面的代码做了一些修改:
using Microsoft.Owin;
using Owin;
.........
[assembly: OwinStartup(typeof(SensorMonHTTP.WebIntf))]
.........
.........
namespace SensorMonHTTP
{
...
public class WebIntf
{
public void Configuration(IAppBuilder app)
{
app.Run(context =>
{
var ConfigPath = new Microsoft.Owin.PathString("/config");
var ConfigApplyPath = new Microsoft.Owin.PathString("/apply_config");
var SensorPath = new Microsoft.Owin.PathString("/");
if (context.Request.Path == SensorPath)
{
return context.Response.WriteAsync(GetSensorInfo());
/* Returns JSON string with sensor information */
}
else if (context.Request.Path == ConfigPath)
{
/* Generate HTML dynamically to list out available sensor
information …Run Code Online (Sandbox Code Playgroud)