You use json encoding, which is \” for double quotes. If you use the builtin json support it will be handled. If you print with the debugger, the debugger will again encode the value to display it. C# also uses \” for encoding.
pass json value which contain double quotes to our action method object
I have the following Action Method which accept a JSON object of type Info, inside my asp.net mvc-5:-
[HttpPost]
public ActionResult UserInfo(Info info)
{
Info class
public class Info
{
public string username {get;set;}
public string password {get;set;}
}
now i am testing this action method using FirFox RESTClient and PostMan.
now i can pass for example this JSON without any issues:-
but let say the password contain double quotes inside it. and i pass it as \"
then my action method will still read it as \"
instead of "
.. so i am not sure how to fix it? what type of encoding i need to apply to the json values before submitting them to the action method? or this need to be handled by the action method ? Thanks
Developer technologies | ASP.NET | Other
1 answer
Sort by: Most helpful
-
Bruce (SqlWork.com) 77,926 Reputation points Volunteer Moderator
2022-10-17T15:12:09.02+00:00