0

I would like to use BeginForm to send some data to the server to check them without reloading the page.

If my action is of type void i get a blank page, same when i use EmptyResult. Also tried with Html.BeginForm, same result.

Here's the Code:

view:

@using(Ajax.BeginForm("putData", "Home", null,  new AjaxOptions {HttpMethod = "POST" }, new { target = "_self" }))
{
    @Html.ValidationSummary(false)
    <fieldset style="padding-bottom: 0" id="Settings">
        <legend>Settings</legend>
        ....
                <td width="180" align="right" class="noborder">
                    <button type="submit" id="checkButton">Check</button>
                </td>
            </tr>
        </table>
    </fieldset>
}

controller:

[HttpPost]
public EmptyResult putData(Settings settings)
{
    ...some checking and updating the model
    return new EmptyResult();
}

Hope you guys can help me.

1

1 Answer 1

1

You can use the HTTP 204 No Content status code:

return new HttpStatusCodeResult(204);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.