Error after passing variable from jquery to code in c#
Posted
by
Moraru Viorel
on Stack Overflow
See other posts from Stack Overflow
or by Moraru Viorel
Published on 2012-06-18T14:55:05Z
Indexed on
2012/06/18
15:16 UTC
Read the original article
Hit count: 228
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?
© Stack Overflow or respective owner