Click here to Skip to main content
11,705,993 members (55,241 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Ajax MVC3

I'm a newbie on MVC3.
In my first project, i encounted a wired problem that when i'm using Ajax.BeginForm in view, the controller cannot get the Ajax request, that.., the Request.IsAjaxRequest() returns false. I almostly freak out with it.
Could someone help me?
1. My View page:

    ViewBag.Title = "Home Page";
    Layout = "~/views/shared/_Layout.cshtml";
<div id="tardiv"></div>
2. The _layout.cshtml:
<!DOCTYPE html>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/microsoftajax.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")" type="text/javascript"></script>
3. The controller:
public string PartialView1()
           var bajax = Request.IsAjaxRequest(); // always false!!!
           return "wxyz";
Posted 23-Jun-11 20:27pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Thank you very much, sir.
I found the reason is "UnobtrusiveJavaScriptEnabled" is set to "true" in web.config.
It 's ok when set to false.
I don't understand mvc3 well and need more effort.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 208
1 Sergey Alexandrovich Kryukov 142
2 Inimicos 60
3 ppolymorphe 57
4 ProgramFOX 50
0 OriginalGriff 9,037
1 Sergey Alexandrovich Kryukov 8,417
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,626

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 24 Jun 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100