使用Ajax会产生过时的结果

EDIT

My Ajax form gets correct Id to update a content and a replace option. Submitting is by clicking <input type="submit" value="submit!" />.

Problem: When I clicked on submit I didn't see any update. Second trial gave the expected result. When I refreshed the page the lost record (first hit was successful) was on spot.

Model

[Serializable]
public abstract class AbstractEntity {
    public Guid Id { get; set; }
    public DateTime LastModified { get; set; }
}

[Serializable]
public class Product : AbstractEntity {
    public Product() {
        this.Attachments = new HashSet<Attachment>();
    }
    public String Title { get; set; }        
    public String Commentary { get; set; }
    public DateTime PlacedOn { get; set; }
    public String User { get; set; }
    public ICollection<Attachment> Attachments { get; set; }
}

[Serializable]
public class Attachment {
    public String MimeType { get; set; }
    public String Description { get; set; }
    public String Filename { get; set; }
}

Controller

[HandleError]
public class ProductController : Controller {
    private readonly IDocumentSession documentSession;

    public ProductController(IDocumentSession documentSession) {
        this.documentSession = documentSession;
    }

    public ActionResult ListRecent() {
        return View(ListAll());
    }

    [Audit, HttpPost]
    public ActionResult Delete(Guid id) {
        documentSession.Delete<Product>(documentSession.Load<Product>(id));
        documentSession.SaveChanges();
        return PartialView("ProductsList", ListAll());
    }

    [Audit, HttpPost]
    public ActionResult Create(Product product) {
        if(ModelState.IsValid) {
            documentSession.Store(product); 
            documentSession.SaveChanges();
        }
        return PartialView("ProductsList", ListAll());
    }

    private IEnumerable<Product> ListAll() {
        return documentSession.Query<Product>().ToArray();
    }
}

Views ('scriptless')

Layout

<head>
    <title>@ViewBag.Title</title>        
    <link href="@Url.Content("~/Content/stylesheets/normalize.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/stylesheets/site.core.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.7.2.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
</head>
<body>
    <div id="main-wrapper">
        <div id="header">[@Html.ActionLink("List", "ListRecent", "Product")]</div>
        <div id="content">@RenderBody()</div>
    </div>        
</body>

ListRecent.cshtml

@model IEnumerable<lamp.DomainLayer.Entities.Product>
@{ 
    ViewBag.Title = "ListRecent";
    var options = new AjaxOptions {
        InsertionMode = InsertionMode.Replace,
        UpdateTargetId = "productsList"        
    };
}

<h2>List</h2>

@Html.Partial("ProductsList", Model)

@using(Ajax.BeginForm("Create", "Product", options)) {
    <fieldset>
        <p>
            <label class="autoWidth">Title</label>
            @Html.Editor("Title")
            @Html.ValidationMessage("Title")
        </p>
        <p>
            <label class="autoWidth">Commentary</label>
            @Html.TextArea("Commentary")
            @Html.ValidationMessage("Commentary")
        </p>
        @* Some fields I have omitted.. *@

        <input type="submit" value="submit" />
        <input type="reset" value="clear" />

    </fieldset>
}

ProductsList.cshtml

@model IEnumerable<lamp.DomainLayer.Entities.Product>
@{
    var options = new AjaxOptions {
        InsertionMode = InsertionMode.Replace,
        UpdateTargetId = "productsList"
    };
}

<div id="productsList">
    @foreach(var p in Model) {
        <div class="productCard">
            <p class="title"><strong>Title</strong>: @p.Title</p>
            <p class="author"><strong>User</strong>: @p.User</p>
            <p class="date"><strong>Placed on</strong>: @idea.PlacedOn.ToShortDateString()</p>
            <p class="link">@Html.ActionLink("details", "Details", "Product")</p>
            <p class="link">
                @using(Ajax.BeginForm("Delete", "Product", new { id = p.Id }, options))  {                
                    <input type="submit" value="you!" />
                }
            </p>
        </div>
    }
</div>

I guess it is IE's fault (precisely the way,how IE cache AJAX requests). Look here-it could be solution:

http://viralpatel.net/blogs/ajax-cache-problem-in-ie/

Ok. Darin was right! I found out that changing my controller code to this one:

private IEnumerable<Product> ListAll() {
    return documentSession
       .Query<Product>()
       .Customize((x => x.WaitForNonStaleResults()))
       .ToArray();
}

fixes everything.

.Customize((x => x.WaitForNonStaleResults()))

is the solution!

Thanks everyone!