Javascript 迁移到ASP.NET核心时出现JsonRequestBehavior问题
我正在将一个应用程序从.NET4.5迁移到Core3.1,我遇到了一个奇怪的问题。这就是我的控制器过去的样子Javascript 迁移到ASP.NET核心时出现JsonRequestBehavior问题,javascript,c#,json,asp.net-core,json.net,Javascript,C#,Json,Asp.net Core,Json.net,我正在将一个应用程序从.NET4.5迁移到Core3.1,我遇到了一个奇怪的问题。这就是我的控制器过去的样子 public ActionResult GetNById(int id) { var model = cerRepo.GetNById(id); return Json(model, JsonRequestBehavior.AllowGet); } public ActionResult GetAllKO() {
public ActionResult GetNById(int id)
{
var model = cerRepo.GetNById(id);
return Json(model, JsonRequestBehavior.AllowGet);
}
public ActionResult GetAllKO()
{
var result = cerRepo.GetAllKO();
return Json(result, JsonRequestBehavior.AllowGet);
}
#endregion
public ActionResult GetAllUL()
{
var result = cerRepo.GetAllUL();
return Json(result, JsonRequestBehavior.AllowGet);
}
#endregion
public ActionResult GetHN (string str)
{
var result = cerRepo.GetHNS (str);
return Json(result, JsonRequestBehavior.AllowGet);
}
public ActionResult GetGrP (string id )
{
var result = cerRepo.GetGrP(id);
return Json(result, JsonRequestBehavior.AllowGet);
}
}
我使用的是JsonRequestBehavior.AllowGet
,但我没有在Core中使用它,因为它不再使用了,对吗?现在我的控制器看起来像这样
public ActionResult GetNById(int id)
{
var model = cerRepo.GetNById(id);
return Json(model);
}
public ActionResult GetAllKO()
{
var result = cerRepo.GetAllKO();
return Json(result);
}
#region action :: get all street
public ActionResult GetAllUL()
{
var result = cerRepo.GetAllUL();
return Json(result);
}
public ActionResult GetHN(string str)
{
var result = cerRepo.GetHNS(str);
return Json(result);
}
public ActionResult GetGrP(string id)
{
var result = cerRepo.GetGrP(id);
return Json(result);
}
我现在得到一个错误,说
加载资源失败:net::ERR\u连接被拒绝/Controller/GetALLUL
以及
加载资源失败:net::ERR\u连接被拒绝/Controller/GetALLKO
首先,我在任何地方都使用了JsonRequestBehavior,但现在我只得到了GetALLUL&GetALLKO的错误
是什么导致了问题?您看到的问题是什么?对不起,我原来的帖子肯定出了问题,有些东西丢失了。我在控制台
加载资源失败:net::ERR_CONNECTION\u被拒绝:44393/Controller/getalll:1
以及net::ERR_CONNECTION\u被拒绝:44393/Controller/GetAlLKO:1
这两个操作是否返回了大量数据,或者类似的操作执行时间是否比分配给请求的时间还要长(理想情况下,IIS为一个请求分配90秒的时间)。这里只是猜测一下其他请求,但这两个请求都有效。