【问题标题】:How to allow GET request on IIS when JsonRequestBehavior is set to AllowGet当 JsonRequestBehavior 设置为 AllowGet 时如何在 IIS 上允许 GET 请求
【发布时间】:2019-06-25 21:53:32
【问题描述】:

我的 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。

【问题讨论】:

  • 您可以发布代码部分,您将返回结果以查看吗?
  • 我将结果用于 javascript 图表。 " $.get('@Url.Action("Chart_Data_withoutParams", "Graf")'," 这是获取操作
  • 对不起,我看不到附加的图片,这就是我要求在这里发布控制器代码的原因。
  • 我用控制器代码更新了问题 :)
  • 尝试在方法结束时返回您的row,在using 之外。可能发生了一些异常。

标签: c# json asp.net-mvc iis


【解决方案1】:

您可以通过此链接查看它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);
}

【讨论】:

    猜你喜欢
    • 2017-07-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-22
    • 2023-04-02
    • 1970-01-01
    • 2017-01-04
    • 1970-01-01
    • 2014-07-24
    相关资源
    最近更新 更多