[英]Ajax - error on .cshtml call
我有下一个问题:我正在本地主机上创建对.cshtml文件的ajax调用...可以正常工作,但是在服务器上上传时会引发错误“禁止(403)”
这是我的ajax电话:
$.ajax({
type: "GET",
url: "~/MyProcessPage.cshtml",
contentType: "application/x-www-form-urlencoded",
data: { id: 1 },
crossDomain: true,
success: function (res) {
console.log(res);
},
error: function (res) { console.log(res); },
dataType: 'json'
});
这是我的C#代码:
if (HttpContext.Current.Request.HttpMethod == "GET")
{
var id= Convert.ToInt32(Request.QueryString["id"]);
Response.Write(id);
}
请注意,我正在使用剃须刀,但未使用MVC!
谢谢!
也许您更改网址
$.ajax({
type: "GET",
url: '@Url.Content("~/MyProcessPage.cshtml")',
contentType: "application/x-www-form-urlencoded",
data: { id: 1 },
crossDomain: true,
success: function (res) {
console.log(res);
},
error: function (res) { console.log(res); },
dataType: 'json'
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.