本文整理汇总了C#中RouteCollection.ForController方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.ForController方法的具体用法?C# RouteCollection.ForController怎么用?C# RouteCollection.ForController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.ForController方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Register
public static void Register(RouteCollection routes)
{
routes.ForController<HomeController>()
.MapRoute(Home.Get(), c => c.Index);
routes.ForController<MonstersController>()
.MapRoute(MonsterList.Get(), c => c.List)
.MapRoute(MonstersInCategory.Get(), c => c.ListCategory)
.MapRoute(MonsterDetail.Get(), c => c.ShowNewOrExisting)
.MapRoute(AddEditMonster, c => c.SaveNewOrExisting)
.MapRoute(DoDeleteMonster, c => c.Delete)
.MapRoute(AdvancedSearch.Get(), c => c.Search);
}
示例2: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.ForController<HomeController>()
.MapRoute(Home.Get(), c => c.Home)
.MapRoute(Literal1.Get(), c => c.LiteralPath)
.MapRoute(Path1Arg.Get(), c => c.OneIntArg)
.MapRoute(Path2Args.Get(), c => c.TwoArgs)
.MapRoute(Path1String.Get(), c => c.OneString)
.MapRoute(QueryDateRange.Get(), c => c.DateRange)
.MapRoute(PostDateRange, c => c.DateRange)
.MapRoute(UploadForm.Get(), c => c.UploadForm)
.MapRoute(UploadAFile, c => c.UploadAFile)
;
// Always declare this last:
routes.ForController<HomeController>()
.MapRoute(Get(CatchAll), c => c.NotFound);
}
示例3: AddTranslation_ConfigurationValidateRoutePrefixIsFalse_IgnoresMissingRoutePrefixAttribute
public void AddTranslation_ConfigurationValidateRoutePrefixIsFalse_IgnoresMissingRoutePrefixAttribute()
{
// Arrange
Configuration.AcceptedCultures.Add("de");
Configuration.ValidateRoutePrefix = false;
RouteCollection routeCollection = new RouteCollection();
routeCollection.MapRoute("Home", "Home", new { controller = "MissingAttribute", action = "Index" }, null);
// Act
routeCollection.ForController<MissingAttributeController>().ForAction(x => x.Index()).SetRoutePrefix("de")
.AddTranslation("Start", "de");
}
示例4: AddTranslation_NullController_ThrowsArgumentNullException
public void AddTranslation_NullController_ThrowsArgumentNullException()
{
// Arrange
RouteCollection routeCollection = new RouteCollection();
// Act
routeCollection.ForController(null).ForAction("Index").AddTranslation("Start", "de");
}
示例5: AddTranslation_MissingRoutePrefixAttribute_ThrowsInvalidOperationException
public void AddTranslation_MissingRoutePrefixAttribute_ThrowsInvalidOperationException()
{
// Arrange
Configuration.AcceptedCultures.Add("de");
RouteCollection routeCollection = new RouteCollection();
routeCollection.MapRoute("Home", "Home", new { controller = "MissingAttribute", action = "Index" }, null);
// Act
routeCollection.ForController<MissingAttributeController>().ForAction(x => x.Index()).SetRoutePrefix("de")
.AddTranslation("Start", "de");
}