0

ページをリロードせずにデータをチェックするために、BeginForm を使用してサーバーにデータを送信したいと考えています。

アクションのタイプが void の場合、EmptyResult を使用する場合と同じように、空白のページが表示されます。Html.BeginFormでも試してみましたが、同じ結果です。

コードは次のとおりです。

見る:

@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>
}

コントローラ:

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

皆さんが私を助けてくれることを願っています。

4

1 に答える 1

1

HTTP 204 No Content ステータス コードを使用できます。

return new HttpStatusCodeResult(204);
于 2013-01-27T02:08:03.403 に答える