我在 JavaSctipt 中生成一个 URL。第一次生成此 URL 时,我得到了正确的 URL:例如**http://localhost:54415/NffCall/Details/DK/6607726**
但是下次我生成链接时,我会得到前一个链接与当前参数的组合:例如http://localhost:54415/NffCall/Details/DK/6607726/DK/6608146
生成我的 URL 的代码如下所示:
var actionUrlBase = '@Url.Action("Details", "NffCall")';
var actionUrl = actionUrlBase + '/' + countryCode + '/' + orderNumber;
window.location.href = actionUrl;
我应该怎么做才能每次生成正确的链接?
编辑:我将粘贴 RouteCollection 的样子:
routes.MapRoute(
name: "CountryCodeOrderNumberDetails",
url: "{controller}/{action}/{countryCode}/{orderNumber}",
defaults: new { controller = "NffCall", action = "Details", countryCode = (string)null, orderNumber = (int?)null },
constraints: new { countryCode = "[a-zA-Z]{2}", orderNumber = "[0-9]+" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);