正在读取ASP.NET中的signup[product][handle]等参数



我需要从Context.Request中读取参数,该请求的格式如下:

url?event=open&signup[customer][first_name]=John&signup[customer][last_name]=Doe&signup[payment_profile][card_number]=xxxxxxxx

有没有一种简单的方法可以将其解析为c#对象?建议将其解析为NameValueCollection,还是将其解析成复杂的?

我不熟悉这种发布数据的方式,我甚至不知道当你这样做时它叫什么,有人愿意填写我吗?谢谢

如果你感兴趣,这是张贴东西的方式:

<form method="post" action="https://....">   
  <input type="hidden" name="signup[product][handle]" value="basic" />
  <input type="text" name="signup[customer][first_name]" />
  <input type="text" name="signup[customer][last_name]" />
  <input type="text" name="signup[customer][email]" />
  <input type="text" name="signup[payment_profile][first_name]" />
  <input type="text" name="signup[payment_profile][last_name]" />
  <input type="text" name="signup[payment_profile][card_number]" />
  <input type="text" name="signup[payment_profile][expiration_month]" />
  <input type="text" name="signup[payment_profile][expiration_year]" />
  <input type="submit" value="Sign Up" />
</form>

您可以通过以下方式将查询字符串解析为NameValueCollection:

var nvc = new NameValueCollection();
nvc.Add(HttpUtility.ParseQueryString(Request.Params));

相关内容

最新更新