hi
in my index view i have a partial view for send new comments:
@model NewsViewModel
@Html.Action("create", "Comment", new { NewsId = Model.Id })
my code in comment control is :
[HttpGet]
public ActionResult Create(int NewsId)
{
ModelState.Clear();
return PartialView();
}
[HttpPost]
public ActionResult Create(Comments comments)
{
if (ModelState.IsValid)
{
db.Comments.Add(comments);
db.SaveChanges();
ModelState.Clear();
return PartialView();
}
return PartialView();
}
my code in Create View:
@model Nezam.Models.Comments
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset class="fieldset">
<legend class="legend">ارسال نظر</legend>
<div class="select">
@Html.LabelFor(model => model.Name)
</div>
<div class="input">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="select">
@Html.LabelFor(model => model.Email)
</div>
<div class="input">
@Html.EditorFor(model => model.Email)
@Html.ValidationMessageFor(model => model.Email)
</div>
<div class="select">
@Html.LabelFor(model => model.Body)
</div>
<div class="textarea">
@Html.EditorFor(model => model.Body)
@Html.ValidationMessageFor(model => model.Body)
</div>
<input type="text" name="NewsId" value="@ViewBag.Id" style="display:none" />
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Everything is working properly, But When i Refresh Browser (firefox), that ask me :
to display this page , firefox must send information that will repeat action(such as a search or order confirmation) that performed earlier,
next i click "resend" and new record add again .
now what can i do for this problem ?