Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 给出潜在危险请求的瑞典字符。Ajax调用中的form值错误_C#_Asp.net Mvc_Jquery - Fatal编程技术网

C# 给出潜在危险请求的瑞典字符。Ajax调用中的form值错误

C# 给出潜在危险请求的瑞典字符。Ajax调用中的form值错误,c#,asp.net-mvc,jquery,C#,Asp.net Mvc,Jquery,在我看来,我正在从Ajax调用一个控制器函数 $.ajax({ type: "POST", url: "@Url.Action("GetSelectedItemsForRoleId","User")", data: { optionLabel: '@CommonResource.DropdownNoValueText', optionValue: null, selectedValue: null, filterValue: 0 }, success: funct

在我看来,我正在从Ajax调用一个控制器函数

$.ajax({
    type: "POST",
    url: "@Url.Action("GetSelectedItemsForRoleId","User")",
    data: { optionLabel: '@CommonResource.DropdownNoValueText', optionValue: null, selectedValue: null, filterValue: 0 },
    success: function (result) {
        alert('success');
        var departmentDropdown = $('#RoleId').data("DropDownList");
        departmentDropdown.setDataSource(result);
    },
    error: function(XMLHttpRequest, textStatus, errorThrown)
    {
        alert('XMLHttpRequest ' + XMLHttpRequest);
        alert('textStatus ' + textStatus);
        alert('errorThrown ' + errorThrown);
        //some stuff on failure
    },
    dataType: "json",
    traditional: true,
    async: false
});  
CommonResource.DropdownNoValueText
-Välj-

我在故障块中得到以下错误:

从客户端检测到潜在危险的request.form值

我的控制器签名如下所示:

public ActionResult GetSelectedItemsForRoleId(string optionLabel, string optionValue, string selectedValue, int filterValue)  
我试图将
ValidateInput
注释置于此函数上方,并将其设置为false。
执行此操作后,字符串显示为
-Vä;lj-

产生这种情况的原因是什么?我如何推导原始文本,即
-Välj-

更新
我进一步尝试了两件事:

  • 我直接用
    -Välj-
    替换了
    @CommonResource.DropdownNoValueText
    。现在我没有得到任何错误(但这不是正确的解决方案,因为这无法解决语言特性)
  • 我将
    CommonResource
    中的
    DropdownNoValueText
    替换为类似于eee的内容,这样也不会给出错误(但即使这样也不是解决方案)

  • 相关,可能重复这是因为ModelBinder在XSS尝试中遇到一些它认为不友好的字符,通常是
    。我想问题是因为ächaracter。@Tomalak:我不能在页面中放置ValidateValse,因为它会导致不正确或有害的输入数据。我只在下拉列表中应用这个,这个字符串值是硬编码的。请看我更新的问题。