[英]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.