我正在尝试将“/”路由到某个虚拟 url,例如 www.abc.com/india,但 ui 无法路由它。
如何在 MVC 中路由默认 Url。
我已经写了这是 route.config
routes.MapRoute(
name: "HomePage",
url: "/",
defaults: new { controller = "Home", action = "index" }
);
我的测试功能是
[TestMethod]
public void Home_Index_test_with_no_Parameter()
{
var context = new StubHttpContextForRouting(requestUrl: "~/");
var routes = new RouteCollection();
RouteConfig.RegisterRoutes(routes);
// Act
var routeData = routes.GetRouteData(context);
// Assert
Assert.IsNotNull(routeData, "~/ url is getting routed properly");
Assert.AreEqual("home", routeData.Values["controller"],
"~/ url is not getting routed properly");
Assert.AreEqual("index", routeData.Values["action"], "~/ url is not getting routed properly");
}
但是这个测试失败了