如何在asp.net C#代码中将自己的自定义文件属性添加到http多部分表单?

我已经使用Visual Studio 2015中的WebSite模板成功创建了一个C#项目。我修改了“Default.aspx”以包含:

  

我还修改了Default.aspx.cs,如下所示:

 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Data/") + FileUpload1.FileName); } } } 

我使用类库模板创建DLL /处理程序,以拦截上传文件Web请求,如下所示:

 using System; using System.Web; namespace WebRequestInterceptorModule { public class Class1 : IHttpHandler { public bool IsReusable { get { return false; } } public void ProcessRequest(HttpContext context) { HttpRequest request = context.Request; System.Collections.Specialized.NameValueCollection nvc = request.Params; string test = "hello"; // Example #4: Append new text to an existing file. // The using statement automatically flushes AND CLOSES the stream and calls // IDisposable.Dispose on the stream object. using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Dining Room\Documents\WriteLines2.txt", true)) { file.WriteLine(test); } } } } 

我通过修改web.config成功注册了上面的处理程序,如下所示:

        

我知道处理程序确实拦截了上传请求,因为每次执行上传时都会看到生成的文件“WriteLines”。

总而言之,文件上传工作正常,我能够使用处理程序/ DLL成功拦截文件上传请求。

我对社区的问题是:假设我想要附加一个自定义字符串属性以及正在上传的文件(即类似于上周的“这些是上周重要的注释”)我该怎么做?

为了尝试回答我自己的问题,我试图在我的处理程序本身放置一个断点并调试“request”对象。 这是我看到的:

在此处输入图像描述

我看到一个名为“QueryString”的东西恰好是空字符串(“”)。 我可以在那里发表评论吗? 如果是这样,我如何修改Default.apsx以更新QueryString?