简体   繁体   English

升级到 RC MVC 后,IsAjaxRequest 始终为 false

[英]IsAjaxRequest is always false after upgrade to RC MVC

I updated the AJAX scripts and assembly referenced as per release notes.我更新了根据发行说明引用的 AJAX 脚本和程序集。 However, IsAjaxRequest still always returns false despite it actually being such a request.然而,尽管 IsAjaxRequest 实际上是这样一个请求,它仍然总是返回 false。 How do I resolve this?我该如何解决?

As I understand you are using MS Ajax library.据我了解,您正在使用 MS Ajax 库。 You should update your MicrosoftMvcAjax.js too.你也应该更新你的 MicrosoftMvcAjax.js。 It was changed.它被改变了。

I did not have a problem using RC1 Updated ... As a test I added this action to the Home Controller我使用 RC1 Updated 没有问题......作为测试,我将此操作添加到 Home Controller

public ActionResult Test()
{
    ifRequest.IsAjaxRequest())
        return PartialView();
    return new EmptyResult();
}

and this to the Home/Index.aspx file这到 Home/Index.aspx 文件

Test Target Created Views/Home/Test.ascx 测试目标创建的视图/主页/Test.ascx
 </br>This is a test

and added the Ajax Javascript Files to the Master Page并将 Ajax Javascript 文件添加到母版页


In response to comments I added an AjaxForm to the Index.aspx and it worked为了回应评论,我向 Index.aspx 添加了一个 AjaxForm 并且它起作用了

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="indexHead" ContentPlaceHolderID="head" runat="server"> <title>Home Page</title> </asp:Content> <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> <h2><%= Html.Encode(ViewData["Message"]) %></h2> <p> To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>. </p> <%= Ajax.ActionLink("Test", "Test", new AjaxOptions{ UpdateTargetId="TestTarget", InsertionMode=InsertionMode.InsertAfter} ) %> <div id="TestTarget">Test Target</div> <% using(Ajax.BeginForm("Test", new AjaxOptions{ UpdateTargetId="TestTarget", InsertionMode=InsertionMode.InsertAfter} ) ){%> <button type="submit" >click me</button> <% } %> </asp:Content>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM