本文整理汇总了C#中RouteCollection.MapRoot方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.MapRoot方法的具体用法?C# RouteCollection.MapRoot怎么用?C# RouteCollection.MapRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.MapRoot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RootRouteMatchIsCaseInsensitive
public void RootRouteMatchIsCaseInsensitive()
{
var routes = new RouteCollection();
routes.MapRoot("Patients", "Index");
var tokenizer = new RoutingBasedUrlTokenizer(routes);
tokenizer.Context = TestFactory.CreateMockContext("~/");
var urlInfo = tokenizer.TokenizeUrl("/VDIR", new Uri("http://localhost/VDIR"), true, "/vdir");
Assert.AreEqual("Patients", urlInfo.Controller);
Assert.AreEqual("Index", urlInfo.Action);
}
示例2: InvalidUrlThrows404
public void InvalidUrlThrows404()
{
var routes = new RouteCollection();
routes.MapRoot("Patients", "Index");
var tokenizer = new RoutingBasedUrlTokenizer(routes);
tokenizer.Context = TestFactory.CreateMockContext("~/Login");
try
{
tokenizer.TokenizeUrl("/Login", new Uri("http://localhost/Login"), true, "/");
Assert.Fail("Should throw 404");
}
catch (HttpException ex)
{
Assert.AreEqual(404, ex.GetHttpCode());
}
}
示例3: MappingRoot
public void MappingRoot()
{
var routes = new RouteCollection();
routes.MapRoot("Patients", "Index");
Assert.AreEqual("Patients", routes.Root().Values["controller"]);
Assert.AreEqual("Index", routes.Root().Values["action"]);
}