我了解如何将数据从C#发送到网页。但是,在Asp.net中如何检索发布数据。
这是我的将数据发送到网页的课程
我应该把这个变量放在什么地方。 Request.Query [ “”]
class PostData
{
private WebRequest request;
private Stream dataStream;
public PostData(String url)
{
request = WebRequest.Create(url);
}
public bool PostDataToWeb(String data)
{
byte[] byteArray = Encoding.UTF8.GetBytes(data);
dataStream = request.GetRequestStream();
request.Method = "POST";
request.ContentType = "application/x-www-formurlencoded";
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
return true;
}
}
我的网页类--->这是webmatrix中的cshtml文件
@{
Layout = "~/_SiteLayout.cshtml";
Page.Title = "CMS Home Page";
if(IsPost)
{
//whats the input am i supposed to input here?
String a = Request.Form[""];
}
}