I am calling a controller function from Ajax in my view
$.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 is -Välj-
I get the following error in failure block :
potentially dangerous request.form value was detected from the client
My controller signature looks like this:
public ActionResult GetSelectedItemsForRoleId(string optionLabel, string optionValue, string selectedValue, int filterValue)
I tried to put ValidateInput
annotation above this function and set it to false.
After doing that the string appears as -Välj-
.
What is the cause of this and how can I derive the original text i.e. -Välj-
?
Update:
I have further tried with two things:
- I replaced
@CommonResource.DropdownNoValueText
directly with-Välj-
. Now I don't get any error.(But this isn't the correct solution as this won't resolve the lingustic feature). - I replaced
DropdownNoValueText
inCommonResource
with something else like eee which also does not give error.(But even this isn't the solution).