本文整理汇总了C#中RouteCollection.MapCodeRoutes方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.MapCodeRoutes方法的具体用法?C# RouteCollection.MapCodeRoutes怎么用?C# RouteCollection.MapCodeRoutes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.MapCodeRoutes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
CodeRoutingSettings.Defaults.RouteFormatter = args =>
Regex.Replace(args.OriginalSegment, @"([a-z])([A-Z])", "$1-$2").ToLowerInvariant();
routes.MapCodeRoutes(typeof(Controllers.HomeController));
}
示例2: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapCodeRoutes(
rootController: typeof(Controllers.HomeController)
);
routes.MapCodeRoutes(
baseRoute: "Account",
rootController: typeof(MvcAccount.AccountController),
settings: new CodeRoutingSettings {
EnableEmbeddedViews = true,
Configuration = new MvcAccount.AccountConfiguration {
AccountRepositoryResolver = () => new Models.TestAccountRepository(),
PasswordServiceResolver = () => new MvcAccount.ClearTextPasswordService()
}
}
);
}
示例3: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapCodeRoutes(
rootController: typeof(Controllers.HomeController),
settings: new CodeRoutingSettings { UseImplicitIdToken = true }
);
}
示例4: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//routes.MapRoute(
// name: "Default",
// url: "{controller}/{action}/{id}",
// defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
//);
routes.MapCodeRoutes(typeof(Controllers.HomeController));
ContactConfiguration.Defaults.From = "[email protected]";
routes.MapCodeRoutes(
baseRoute: "Contact",
rootController: typeof(ContactController),
settings: new CodeRoutingSettings {
EnableEmbeddedViews = true,
Configuration = new ContactConfiguration {
To = "[email protected]"
}
}
);
routes.MapCodeRoutes(
baseRoute: "CustomContact",
rootController: typeof(ContactController),
settings: new CodeRoutingSettings {
EnableEmbeddedViews = true,
Configuration = new ContactConfiguration {
To = "[email protected]",
ContactSenderResolver = () => new Models.CustomContactSender()
}
}
);
}
示例5: Run
void Run(Type controller, CodeRoutingSettings settings = null, bool useBinder = false)
{
if (settings == null) {
settings = new CodeRoutingSettings();
}
var routes = new RouteCollection();
routes.MapCodeRoutes(controller, settings);
var httpContextMock = new Mock<HttpContextBase>();
httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/Archive/02");
var httpResponseMock = new Mock<HttpResponseBase>();
httpContextMock.Setup(c => c.Response).Returns(httpResponseMock.Object);
var routeData = routes.GetRouteData(httpContextMock.Object);
var controllerInstance = (Controller)Activator.CreateInstance(controller);
controllerInstance.ValidateRequest = false;
var requestContext = new RequestContext(httpContextMock.Object, routeData);
var controllerContext = new ControllerContext(requestContext, controllerInstance);
controllerInstance.ValueProvider = new ValueProviderCollection(new IValueProvider[] { new RouteDataValueProvider(controllerContext) });
((IController)controllerInstance).Execute(requestContext);
string expected = (useBinder) ? "02" : "00";
httpResponseMock.Verify(c => c.Write(It.Is<string>(s => s == expected)), Times.AtLeastOnce());
}