当前位置: 首页>>代码示例>>C#>>正文


C# RouteCollection.MapCodeRoutes方法代码示例

本文整理汇总了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));
      }
开发者ID:brettveenstra,项目名称:MvcCodeRouting,代码行数:9,代码来源:RouteConfig.cs

示例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()
               }
            }
             );
        }
开发者ID:rachidh,项目名称:MvcAccount,代码行数:18,代码来源:RouteConfig.cs

示例3: RegisterRoutes

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapCodeRoutes(
            rootController: typeof(Controllers.HomeController),
            settings: new CodeRoutingSettings { UseImplicitIdToken = true }
        );
        }
开发者ID:DarrenPluss,项目名称:PhotoSharing,代码行数:9,代码来源:RouteConfig.cs

示例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()
               }
            }
         );
      }
开发者ID:vaklove,项目名称:samples.mvccontact,代码行数:37,代码来源:RouteConfig.cs

示例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());
        }
开发者ID:brettveenstra,项目名称:MvcCodeRouting,代码行数:31,代码来源:RegexConstraintBehavior.cs


注:本文中的RouteCollection.MapCodeRoutes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。