62,046
社区成员
发帖
与我相关
我的任务
分享
<body>
<input type="button" onclick="test('get')" value="get" />
<input type="button" onclick="test('post')" value="post" />
<input type="button" onclick="test('put')" value="put" />
<input type="button" onclick="test('delete')" value="delete" />
<script src="../../js/jquery-1.9.1.min.js"></script>
<script>
var test = function (m) {
$.ajax({
type: m,
dataType: "text",
url: "../../WebHandler/testValid.ashx",
data: [{ name: "A", value: "A1" }],
success: function (data) {
alert(data);
},
error: function (e) {
alert(e.statusText);
}
});
}
</script>
</body>
HttpRequest Request = HttpContext.Current.Request;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string method = context.Request.QueryString["method"];
method = Request.RequestType;
string a = context.Request["A"];
context.Response.Write(string.Format("method:{0},value:{1}",method,a));
}
可以得到get post 得不到 put 和 delete
<body>
<input type="button" onclick="test('get')" value="get" />
<input type="button" onclick="test('post')" value="post" />
<input type="button" onclick="test('put')" value="put" />
<input type="button" onclick="test('delete')" value="delete" />
<script src="../../js/jquery-1.9.1.min.js"></script>
<script>
var test = function (m) {
$.ajax({
type: m,
dataType: "text",
url: "../../WebHandler/testValid.ashx",
data: [{ name: "A", value: "A1" }],
success: function (data) {
alert(data);
},
error: function (e) {
alert(e.statusText);
}
});
}
</script>
</body>
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string method = context.Request.QueryString["method"];
string a = context.Request["A"];
context.Response.Write(string.Format("method:{0},value:{1}",method,a));
}
结果,行不通。
context.Request.QueryString["method"],接收不到method[/quote]
不好意思,我没说清楚,method这个是参数来的querystring定义的是get参数。
<body>
<input type="button" onclick="test('get')" value="get" />
<input type="button" onclick="test('post')" value="post" />
<input type="button" onclick="test('put')" value="put" />
<input type="button" onclick="test('delete')" value="delete" />
<script src="../../js/jquery-1.9.1.min.js"></script>
<script>
var test = function (m) {
$.ajax({
type: m,
dataType: "text",
url: "../../WebHandler/testValid.ashx",
data: [{ name: "A", value: "A1" }],
success: function (data) {
alert(data);
},
error: function (e) {
alert(e.statusText);
}
});
}
</script>
</body>
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string method = context.Request.QueryString["method"];
string a = context.Request["A"];
context.Response.Write(string.Format("method:{0},value:{1}",method,a));
}
结果,行不通。
context.Request.QueryString["method"],接收不到method
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string method = context.Request.QueryString["method"];
}
//选择方法
private void ChoseMethod(string methond, HttpContext context)
{
switch (methond)
{
case "delete":
this.Hand_delete(context);
break;
default:
break;
}
}
//处理方法
private void Hand_delete(HttpContext context)
{
//your code
}
public bool IsReusable
{
get
{
return false;
}
}
<body>
<input type="button" onclick="test('get')" value="get" />
<input type="button" onclick="test('post')" value="post" />
<input type="button" onclick="test('put')" value="put" />
<input type="button" onclick="test('delete')" value="delete" />
<script src="../../js/jquery-1.9.1.min.js"></script>
<script>
var test = function (m) {
$.ajax({
type: m,
dataType: "text",
url: "../../WebHandler/testValid.ashx",
data: [{ name: "A", value: "A1" }],
success: function (data) {
alert(data);
},
error: function (e) {
alert(e.statusText);
}
});
}
</script>
</body>
HttpRequest Request = HttpContext.Current.Request;
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string method = context.Request.QueryString["method"];
method = Request.RequestType;
string a = context.Request["A"];
context.Response.Write(string.Format("method:{0},value:{1}",method,a));
}
可以得到get post 得不到 put 和 delete
[/quote]
你测试过吗?