Reputation: 639
I'm using some POST requests in my project until when I came across a form with
onsubmit="return false;"
<form name="formName" id="formName" action="" method="post" onsubmit="return false;">
...
</form>
This form is submitted by a javascript onclick button function.
All the other request I'm doing are working correctly, but not this one and I strongly believe the onsubmit false is the cause.
Is there anyway to get around this?
**EDIT (Complement) **
thats the POST request
FormUrlEncodedContent formContent = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("a", "b")
});
Task<HttpResponseMessage> post = client.PostAsync(url, formContent);
post.Wait();
Task<string> contents = post.Result.Content.ReadAsStringAsync();
contents.Wait();
Upvotes: 0
Views: 487
Reputation: 3736
Replace this
<form name="formName" id="formName" action="" method="post" onsubmit="return false;">
...
</form>
with
<form name="formName" id="formName" action="urlendpointurl" method="post">
<input type="submit" value="Submit to me">
</form>
In typical Asp.Net MVC app ur urlendpointurl will be like "~/Home/Save"
Upvotes: 2