Avaloth Oath Avaloth Oath - 1 year ago 102
ASP.NET (C#) Question

Ajax.ActionLink takes to a different Page MVC 4.5 Visual studio 2015

i checked all possible stackoverflow and asp.net questions about this subject and couldnt solve my problem.
As the title says my Ajax.ActionLink Redirects to a new page instead of replacing the div i selected. i have loaded all necessary packages
see my code below:
in my Bundles i have this:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(

In Bottom of _Layout page

@RenderSection("scripts", required: false)


@Ajax.ActionLink("New User", "New", "Person", new AjaxOptions
UpdateTargetId = "userTable",
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
OnFailure = "Something unexpected has occured"
},new {@class = "btn btn-primary"})

<div id="usersTable">

@section scripts {...} // Some code to load the table on existing partial that is beeing rendered

New action in Person controller

public PartialViewResult New()
var person = new Person();
return PartialView("_UserForm", person);

PLEASE HELP i have been going on this for days now and honestly i have tried almost everything posted out there.

Edit 1: As a response to jquery.unobtrusive-ajax.js is not loaded correctly, or perhaps being overwritten i have included the browser scripts as they are loaded on the page

<script src="/Scripts/jquery-3.1.1.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/scripts/bootbox.js"></script>
<script src="/Scripts/respond.js"></script>
<script src="/scripts/datatables/jquery.datatables.js"></script>
<script src="/scripts/datatables/datatables.bootstrap.js"></script>
<script src="/scripts/toastr.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>

Answer Source

Instead of this

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(

shouldn't it be this?

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(

The .js file extension is missing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download