I updated the AJAX scripts and assembly referenced as per release notes. However, IsAjaxRequest still always returns false despite it actually being such a request. How do I resolve this?
A:
I did not have a problem using RC1 Updated ... As a test I added this action to the Home Controller
public ActionResult Test()
{
ifRequest.IsAjaxRequest())
return PartialView();
return new EmptyResult();
}
and this to the Home/Index.aspx file
<%= Ajax.ActionLink("Test", "Test", new AjaxOptions{ UpdateTargetId="TestTarget", InsertionMode=InsertionMode.InsertAfter} ) %>
Test TargetCreated Views/Home/Test.ascx
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
</br>This is a test
and added the Ajax Javascript Files to the Master Page
In response to comments I added an AjaxForm to the Index.aspx and it worked
<%@ 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>
Matthew
2009-02-12 19:22:16
i didnt try with actionlink, but it didnt work with ajax form.
zsharp
2009-02-12 19:37:12
+1
A:
As I understand you are using MS Ajax library. You should update your MicrosoftMvcAjax.js too. It was changed.
zihotki
2009-02-18 08:53:37
A:
I am having the same problem in 1.0.
In fact I just created a new MVC application with the code Matthew provided and Request.IsAjaxRequest() always returns true in this new app too?
KevinUK
2009-04-07 14:49:36