Error after passing variable from jquery to code in c#
- by Moraru Viorel
I try to pass variable from jquery to code c# but something is wrong. I have in js this code:
<script type="text/javascript">
var mySerial = '12345';
var fooUrl = '@Url.Action("Foo", "Home")';
window.location.href = fooUrl + '?mySerial' + encodeURIComponent(mySerial);
</script>
in controller :
[HttpPost]
public ActionResult Foo(string mySerial)
{
return View();
}
After execution I keep this url: http://localhost:2214/@Url.Action("Foo",%20"Home")?mySerial12345 and I don't understand where's the problem, can someone help me?