我想我在JQuery和ASP.NET MVC中發現了一些非常奇怪的東西。JQuery的Ajax調用被解析到當前的控制器文件夾,而不是根文件夾
如this question提到的,我有以下JQuery的代碼:
$(function() {
$("#username").click(function() {
$.getJSON("ViewRecord/GetSoftwareChoice", {username:'123'},
function(data) {
alert(data);
});
});
});
ViewRecord
是控制器和GetSoftwareChoice
是操作方法。但爲此產生的URl是
http://localhost/ViewRecord/ViewRecord/GetSoftwareChoice?username=123
很神奇,不是嗎?
爲什麼會出現這種情況?
這是我的路線:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
他們在上一個問題中給出了這個答案。爲什麼要問一個新的? – Talljoe 2009-06-17 05:20:49