I think I found something very weird in JQuery and ASP.NET MVC.
As mentioned in this question, I have the following JQuery code:
$(function() {
$("#username").click(function() {
$.getJSON("ViewRecord/GetSoftwareChoice", {username:'123'},
function(data) {
alert(data);
});
});
});
ViewRecord
is the controller and GetSoftwareChoice
is the action method. But the URl generated for this is
http://localhost/ViewRecord/ViewRecord/GetSoftwareChoice?username=123
Pretty amazing, isn't it?
Why this is the case?
This is my route:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);