[英]Ajax - error on .cshtml call
i have the next problem: i'm creating an ajax call to a .cshtml file... in localhost it works fine, but when uploaded on server it throws an error "Forbidden (403)" 我有下一个问题:我正在本地主机上创建对.cshtml文件的ajax调用...可以正常工作,但是在服务器上上传时会引发错误“禁止(403)”
this is my ajax call: 这是我的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'
});
and this is my C# code: 这是我的C#代码:
if (HttpContext.Current.Request.HttpMethod == "GET")
{
var id= Convert.ToInt32(Request.QueryString["id"]);
Response.Write(id);
}
Please notice i'm using razor but NOT using MVC! 请注意,我正在使用剃须刀,但未使用MVC!
Thanks! 谢谢!
Maybe you shold change the url 也许您更改网址
$.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.