1

Ajax.ActionLinkのupdatetargetidプロパティを使用してdivに部分ビューを表示しているときに、問題が発生します。これは私のコントローラーです-

    [HandleError]
    public class HomeController : Controller
    {
        static NumberViewModel model = new NumberViewModel();

        public ActionResult Index()
        {

            model.IsDivisibleBy3 = (model.CurrentNumber % 3 == 0);

            if (Request.IsAjaxRequest())
            {
                return PartialView("ViewUserControl1", model);
            }

            return View();
        }

        [ActionName("Increment")]
        public ActionResult Increment()
        {
            model.CurrentNumber++;
            return RedirectToAction("Index");
        }
    }

マイインデックスビュー-

  <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">

        function ShowResult() {
            var windowWidth = document.documentElement.clientWidth;
            var windowHeight = document.documentElement.clientHeight;
            leftVal = (windowWidth - 655) / 2;
            topVal = (windowHeight - 200) / 2;       

            $('#result').css({
                "left": leftVal,
                "top": topVal
            });
            $('#background').fadeIn("slow");
        }


    </script>
    <div id="background" class="hiddenDiv">
        <div id="result" class="popupBox">
        </div>
    </div>
   <%= Ajax.ActionLink("Show", "Index", new AjaxOptions() { UpdateTargetId="result", OnComplete="ShowResult", HttpMethod="Get" })%> 
   <%= Html.ActionLink("Increment","Increment") %>

</asp:Content>

これはFFでは機能しますが、IE6-IE8では機能しません。

IEシナリオ-したがって、「表示」をクリックすると、最初に「0は3で割り切れる」と表示されます。「インクリメント」をクリックすると、数値は1になり、3で割り切れなくなります。「表示」をクリックすると、「0は3で割り切れます」と表示されます。

VSでデバッグポイントを保持した後、2回目にリクエストがサーバーにまったく送信されないことがわかりました。その結果、updatetargetiddivが更新されません。

誰かが以前にこの問題に直面したことがありますか?

4

1 に答える 1

3

つまり、複製リクエストをキャッシュしています。これをアクションメソッドに追加するだけです:

        Response.CacheControl = "no-cache";
        Response.Cache.SetETag((Guid.NewGuid()).ToString());

したがって、次のようになります。

[ActionName("Increment")]
    public ActionResult Increment()
    {
        Response.CacheControl = "no-cache";
        Response.Cache.SetETag((Guid.NewGuid()).ToString());
        model.CurrentNumber++;
        return RedirectToAction("Index");
    }
于 2010-07-28T16:34:53.167 に答える