In my current ASP.NET project, we encounter an issue with passing parameters through the URL. Whenever a single quote is passed, the URL automatically changes all single quotes to %27 and the actual JavaScript value reads them as '
I need assistance in maintaining the single quotes as our parameters must accurately match the values provided. Below is a snippet of my code:
public class Model
{
public string example {get; set;}
}
public ActionResult Index(string example)
{
var model = new Model();
model.example = example;
return View(model);
}
Index.cshtml at the bottom ---------------------
<script type="text/javascript">
var example = "@Model.example";
Main();
</script>
Javascript -----------------
console.log(example);
For example: www.example.com?example=Turtle's_Are_Cool will instantly change the URL to => www.example.com?example=Turtle\%27s_Are_Cool and the JavaScript output will be Turtle's_Are_Cool