这似乎是一个受欢迎的问题,但我找不到早期帖子的解决方案。 我试图在控制器'捐赠'中调用行动'收费'
我的网址是这样的
mysite.com/test/
路由就像
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.LowercaseUrls = true;
routes.Add(
new Route("history/buildings/{id}/{action}/{controller}",
new RouteValueDictionary(
new { controller = "home", action = "index", id = "home" }),
new HyphenatedRouteHandler())
);
routes.Add(
new Route("donate/{action}/{id}",
new RouteValueDictionary(
new { controller = "donate", action = "index", id = "donate" }),
new HyphenatedRouteHandler())
);
routes.Add(
new Route("{id}/{action}/{controller}",
new RouteValueDictionary(
new { controller = "home", action = "index", id = "index" }),
new HyphenatedRouteHandler())
);
Ajax
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
url: "/test/donate/charge",
dataType: 'json',
data: JSON.stringify(myData),
这是
mysite.com/donate/charge
看起来不对,但给了我404(查看开发工具中的网络流量)
行动是
[HttpPost]
public JsonResult charge (WebSiteSessions.order ord)
我已经尝试了JsonResult和ActionResult但同样的问题
我想象它有些愚蠢 - 非常感谢帮助