I am currently working with VB.Net and MVC 5. In my project, I have an object that I created using javaScript:
var myEdits = {
listOfIDs: [],
listOfValues : []
};
My goal is to send this object to the controller and proceed to the next view with all the relevant information.
While I am able to successfully stringify the object and send it to the controller using ajax, I face a challenge in rendering the new view upon success.
I attempted to use window.location
along with encodeURIComponent
as follows:
myEdits = encodeURIComponent(JSON.stringify(myEdits));
var postString = ("/ViewDetails/EditConfirmation/" + myEdits);
window.location = postString;
However, I still encounter this error:
A potentially dangerous Request.Path value was detected from the client (:).
This error confuses me as I do not see any colons in the request path:
EditConfirmation/%7B"listOfIDs"%3A%5B"22"%2C"23"%2C"24"%2C"25"%2C"26"%2C"27"%2C"28"%2C"29"%2C"30"%2C"31"%2C"32"%2C"33"%2C"34"%2C"35"%2C"36"%5D%2C"listOfValues"%3A%5B""%2C""%2C""%2C""%2C""%2C""%2C""%2C""%2C""%2C""%2C"Yes"%2C"Yes"%2C"Yes"%2C"Yes"%2C"No"%5D%7D
Can someone advise on the correct method of passing this object via javaScript or jQuery to the controller and ensuring that the server renders the new view?