Here is a line of code in my Controller class:
return JavaScript(String.Format("window.top.location.href='{0}';", Url.Action("MyAction", "MyController")))
Is there a way to make it use the verb=post
version of MyAction
?
Action method only creates the url not the complete hyperlink, to create hyperlink we need to use Html. ActionLink covered next. To access these querystring values in the action method, we can use Request.QueryString like below. CONTROLLER ACTION METHOD public ActionResult Index() { string com = Request.
Yes, there is a difference. Html. ActionLink generates an <a href=".."></a> tag whereas Url. Action returns only an url.
Action(String, String, Object, String)Generates a fully qualified URL to an action method by using the specified action name, controller name, route values, and protocol to use.
You can't use POST by simply navigating to a different URL. (Which is what you'd do by changing location.href.)
Using POST only makes sense when submitting some data. It's not clear from your code what data would actually be POSTed.
If you really want to initiate a POST via javascript try using it to submit a form.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With