javascript - 迁移到 ASP.NET Core 时出现 JsonRequestBehavior 问题
问题描述
我正在将应用程序从 .NET 4.5 迁移到 Core 3.1,但我遇到了一个奇怪的问题。这就是我的控制器过去的样子
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_CONNECTION_REFUSED /Controller/GetALLUL 以及 无法加载资源:net::ERR_CONNECTION_REFUSED /Controller/GetALLKO
我首先在任何地方都使用了 JsonRequestBehavior,但现在我只收到GetALLUL和GetALLKO的错误
什么可能导致问题?
解决方案
推荐阅读
- r - 带有 html 标签的 rhandsontable
- go - OpenShift API - 无法使用配置
- css - Flexbox 有问题 2 列 3 项
- java - 拖放后被拖动的物品消失
- python - Wagtail:为 Multisite 中的每个应用程序设置一个专用的静态文件夹
- php - 处理具有相同错误号的 Mysql 错误
- git - 当应该有合法输出时,Git 分支、差异等在终端中没有显示任何输出
- php - 分段错误(核心转储)Laravel SwiftMailer
- php - 为什么这种日期格式会继续更改为 1970-01-01?
- php - 如何替换满足复杂条件的字符串?