c# - 当 JsonRequestBehavior 设置为 AllowGet 时如何在 IIS 上允许 GET 请求
问题描述
我的 asp.net mvc web 应用程序和应用程序在 localhost 上运行良好,但是在 IIS 服务器上部署后 Json Get 请求被阻止。我将 JsonRequestBehavior 设置为 AllowGet。我允许 IIS 上对所有 http 请求的请求,但仍然出现此错误:
此请求已被阻止,因为在 GET 请求中使用敏感信息可能会泄露给第三方网站。要允许 GET 请求,请将 JsonRequestBehavior 设置为 AllowGet。”
using (cmd = new OracleCommand(query, con))
{
con.Open();
OracleDataAdapter sda = new OracleDataAdapter(cmd);
sda.Fill(dt1);
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in dt1.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in dt1.Columns)
{
row.Add(col.ColumnName, dr[col]);
}
rows.Add(row);
}
return Json(rows, JsonRequestBehavior.AllowGet);
}
IIS 上是否有任何用于过滤请求的设置?
编辑:
将 GET Verb 添加到 IIS 设置后,我收到了新错误:
System.ArgumentException:超出 RecursionLimit。
解决方案
您可以通过此链接查看它https://www.compilemode.com/2015/10/request-has-been-blocked-In-mvc-json-result.html
我无法清楚答案,因为我看不到您的所有代码
[HttpGet]
public JsonResult GetData()
{
List<string> a = new List<string>();
a.Add("A");
return Json(a, JsonRequestBehavior.AllowGet);
}
推荐阅读
- mysql - 从 spark foreach 分区插入 mysql 时记录丢失
- python - Python 抓取的数据返回 None
- git - 无法在 VSCode 中从 Git 推送或拉取,默认情况下 VSCode 推送到错误的分支
- bayesian-networks - 在 python 中使用 BNLEARN 包的贝叶斯网络
- python - pyplot.imshow 和 image.show 之间的区别?
- c - socket编程中客户端如何同时读写
- python - 从文件夹中读取文件并从文件中提取特定密钥并另存为 CSV 文件
- android - 在特定行之后使编辑文本可滚动
- javascript - 获取请求错误,而我可以在浏览器开发工具中看到良好的结果
- java - 未在 STS thymeleaf 中翻译成不同语言的消息