本文整理汇总了C#中RouteCollection类的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection类的具体用法?C# RouteCollection怎么用?C# RouteCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RouteCollection类属于命名空间,在下文中一共展示了RouteCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MapRouteApiControllers
/// <summary>
/// Registers all api controller routes
/// </summary>
/// <param name="routes"></param>
/// <param name="apiControllers"></param>
private void MapRouteApiControllers(RouteCollection routes, IEnumerable<PluginControllerMetadata> apiControllers)
{
foreach (var s in apiControllers)
{
this.RouteControllerPlugin(s.ControllerName, s.ControllerType, routes, "", "", UrlParameter.Optional, "api", isMvc: false);
}
}
开发者ID:phaniarveti,项目名称:Experiments,代码行数:12,代码来源:PluginControllerArea.cs
示例2: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//routes.MapRoute(
// name: "Create",
// url: "Tool/Create",
// defaults: new { controller = "Tool", action = "Create" }
//);
// This route creates a short URL to a specific tool.
// this makes it easy to copy and paste.
// For example, http://localhost/Tool/5
routes.MapRoute(
name: "Launch",
url: "Tool/{id}",
defaults: new { controller = "Tool", action = "View" },
constraints: new { id = @"\d+" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
开发者ID:tebass,项目名称:LtiSamples,代码行数:26,代码来源:RouteConfig.cs
示例3: Init
public void Init() {
_settingsA = new ShellSettings { Name = "Alpha" };
_settingsB = new ShellSettings { Name = "Beta", };
_routes = new RouteCollection();
var rootBuilder = new ContainerBuilder();
rootBuilder.Register(ctx => _routes);
rootBuilder.RegisterType<ShellRoute>().InstancePerDependency();
rootBuilder.RegisterType<RunningShellTable>().As<IRunningShellTable>().SingleInstance();
rootBuilder.RegisterModule(new WorkContextModule());
rootBuilder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>().InstancePerMatchingLifetimeScope("shell");
rootBuilder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>();
rootBuilder.RegisterType<ExtensionManager>().As<IExtensionManager>();
rootBuilder.RegisterType<StubCacheManager>().As<ICacheManager>();
rootBuilder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
rootBuilder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
_rootContainer = rootBuilder.Build();
_containerA = _rootContainer.BeginLifetimeScope(
"shell",
builder => {
builder.Register(ctx => _settingsA);
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerMatchingLifetimeScope("shell");
});
_containerB = _rootContainer.BeginLifetimeScope(
"shell",
builder => {
builder.Register(ctx => _settingsB);
builder.RegisterType<RoutePublisher>().As<IRoutePublisher>().InstancePerMatchingLifetimeScope("shell");
});
}
开发者ID:dioptre,项目名称:nkd,代码行数:33,代码来源:ShellRouteTests.cs
示例4: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
//routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// This controller-per-type route is ideal for GetAll calls.
// It finds the method on the controller using WebAPI conventions
// The template has no parameters.
routes.MapHttpRoute(
name: ControllerOnly,
routeTemplate: "api/{controller}"
);
routes.MapHttpRoute(
name: ControllerAndId,
routeTemplate: "api/{controller}/{id}",
defaults: null, //defaults: new { id = RouteParameter.Optional } //,
constraints: new { id = @"^\d+$" } // id must be all digits
);
// ex: api/lookups/all
// ex: api/lookups/rooms
routes.MapHttpRoute(
name: ControllerAction,
routeTemplate: "api/{controller}/{action}"
);
//PAPA: Commented this out because we wont be using MVC views
//routes.MapRoute(
// name: "Default",
// url: "{controller}/{action}/{id}",
// defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
//);
}
开发者ID:OleksandrKulchytskyi,项目名称:SAPAspNetMvc,代码行数:33,代码来源:RouteConfig.cs
示例5: Register
public void Register(RouteCollection routes)
{
// add catch-all routes for incoming routes that will match dynamically created controllers
for (var n = 0; n < 3 /*ContentTreeRouteRegistrator.MaxDepthForContentTreeUrlSegments*/; n++)
{
var sb = new StringBuilder();
for (var x = 0; x <= n; x++)
{
sb.Append(string.Format("{{nodesegment-{0}}}/", x));
}
AddRoute(routes, string.Format("{0}{{action}}", sb));
}
// add hard coded routes for all instances of this engine type
foreach (var treeNode in treeNodeRepository.GetAll().Where(a => a.Type == this.GetType().AssemblyQualifiedName))
{
var url = treeNodeIdToUrl.GetUrlByTreeNodeId(treeNode.Id);
if (url.StartsWith("/")) url = url.Substring(1);
url = url + "/{action}";
var controllerName = (this.GetType().Name ?? string.Empty).Replace("Controller", string.Empty);
routes.MapRoute(
null,
url,
new { controller = controllerName, action = "Index" }
);
}
}
开发者ID:tyronegroves,项目名称:Bennington,代码行数:29,代码来源:ToolLinkController.cs
示例6: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Plugins", "plugins/{action}", new { controller = "Plugins" });
routes.MapRoute("BackboneDirectAccess", "{*url}", new { controller = "Home", action = "Index" });
}
开发者ID:benjaminramey,项目名称:GoodlyFere.Import.Web,代码行数:7,代码来源:RouteConfig.cs
示例7: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"ApiSearch", // Route name
"artist/search/{search_criteria}/{page_number}/{page_size}", // URL with parameters
new { controller = "Api", action = "Search", page_number = UrlParameter.Optional, page_size = UrlParameter.Optional } // Parameter defaults
);
// /artist/6c44e9c22-ef82-4a77-9bcd-af6c958446d6/albums
routes.MapRoute(
"GetTopAlbums", // Route name
"artist/{artist_id}/albums", // URL with parameters
new { controller = "Api", action = "GetTopAlbums" } // Parameter defaults
);
// /artist/6c44e9c22-ef82-4a77-9bcd-af6c958446d6/albums
routes.MapRoute(
"GetReleases", // Route name
"artist/{artist_id}/releases", // URL with parameters
new { controller = "Api", action = "GetReleases" } // Parameter defaults
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
开发者ID:cvizzini,项目名称:backend-developer-assessment,代码行数:30,代码来源:RouteConfig.cs
示例8: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Match empty URL (~/)
routes.MapRoute(
null,
string.Empty,
new
{
controller = "Bookmarks",
action = "List",
page = 1
}
);
// Match new
routes.MapRoute(
null,
"New",
new
{
controller = "Bookmarks",
action = "New",
page = 1
}
);
// Map numeric pages ~/Page123, ~/Page2
routes.MapRoute(
null,
"Page{page}",
new
{
controller = "Bookmarks",
action = "List"
},
new
{
page = @"\d+"
}
);
// Match Admin
routes.MapRoute(
null,
"Bookmarks/{controller}/{action}",
new
{
controller = "Bookmarks",
action = "List",
page = 1
}
);
routes.MapRoute(
null,
"{controller}/{action}"
);
}
开发者ID:scottmetoyer,项目名称:bookmarks,代码行数:60,代码来源:Global.asax.cs
示例9: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
routes.MapRoute(
name: "Board",
url: "",
defaults: new { controller = "Home", action = "Board" }
);
routes.MapRoute(
name: "Vote",
url: "vote",
defaults: new { controller = "Home", action = "Index" }
);
routes.MapRoute(
name: "Login",
url: "login",
defaults: new { controller = "Account", action = "Login" }
);
routes.MapRoute(
name: "Registration",
url: "registration",
defaults: new { controller = "Account", action = "Register" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}",
defaults: new { controller = "Home", action = "Index" }
);
}
开发者ID:san4oz,项目名称:AskGenerator,代码行数:35,代码来源:RouteConfig.cs
示例10: Setup
public void Setup()
{
RouteAssert.UseAssertEngine(new NunitAssertEngine());
routes = new RouteCollection();
routes.MapAttributeRoutesInAssembly(typeof(HomeAttrController));
}
开发者ID:EricRohlfs,项目名称:MvcRouteTester,代码行数:7,代码来源:VerbedAttrControllerTests.cs
示例11: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "ListTopRoute",
url: "ListTop/{page}",
defaults: new { controller = "Page", action = "ListTopPages", page = UrlParameter.Optional }
);
routes.MapRoute(
name: "ListRoute",
url: "List/{category}/{idCategory}/{page}",
defaults: new { controller = "Page", action = "List", category = UrlParameter.Optional, idCategory = UrlParameter.Optional, page = UrlParameter.Optional }
);
routes.MapRoute(
name: "ArchiveRoute",
url: "Archive/{page}/{id}",
defaults: new { controller = "Page", action = "Index", page = UrlParameter.Optional, id = UrlParameter.Optional }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
开发者ID:raowyr,项目名称:BlogProject,代码行数:30,代码来源:RouteConfig.cs
示例12: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Default", "", new { controller = "LogViewer", action = "Index", id = UrlParameter.Optional }
);
}
开发者ID:brisebois,项目名称:WindowsAzureLogger,代码行数:7,代码来源:RouteConfig.cs
示例13: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//routes.MapRoute(
// "Default", // Route name
// "{controller}/{action}", // URL with parameters
// new { controller = "Tasks", action = "Index"} // Parameter defaults
// );
routes.MapRoute("About", "{controller}/{action}", new { controller = "Tasks", action = "About" });
routes.MapRoute(
"Tasks", "{controller}/{action}/{project}", new { controller = "Tasks", action = "TaskList" });
routes.MapRoute(
"ImageRoute",
"{controller}/{action}/{id}",
new { controller = "Tasks", action = "Images" });
routes.MapRoute(
"ClearServerCache", "{controller}/{action}", new { controller = "Tasks", action = "ClearServerCache" });
routes.MapRoute(
"ImportData",
"{controller}/{action}/{project}",
new { controller = "Tasks", action = "ImportData" });
}
开发者ID:issafram,项目名称:TeamDashboardKanban,代码行数:28,代码来源:Global.asax.cs
示例14: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("cache.manifest", "cache.manifest", new { controller = "Resources", action = "Manifest" });
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
routes.MapRoute(
name: "Readability",
url: "{controller}/{action}/{url}",
defaults: new { controller = "Readability", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
开发者ID:alexbeletsky,项目名称:aspnet.mobile,代码行数:25,代码来源:Global.asax.cs
示例15: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "file_upload",
url: "file/upload/{file}",
defaults: new { controller = "Blog", action = "FileUpload", file = UrlParameter.Optional }
);
routes.MapRoute(
name: "manage_blog",
url: "manage/blog/{action}/{id}",
defaults: new { controller = "Blog", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "manage_product",
url: "manage/product/{action}/{id}",
defaults: new { controller = "Product", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "manage",
url: "manage/{action}/{id}",
defaults: new { controller = "Management", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Home", id = UrlParameter.Optional }
);
}
开发者ID:JJarczyk12,项目名称:Price-Point,代码行数:34,代码来源:RouteConfig.cs
示例16: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// This controller-per-type route is ideal for GetAll calls.
// It finds the method on the controller using WebAPI conventions
// The template has no parameters.
//
// ex: api/sessionbriefs
// ex: api/sessions
// ex: api/persons
routes.MapHttpRoute(
name: ControllerOnly,
routeTemplate: "api/{controller}"
);
// This is the default route that a "File | New MVC 4 " project creates.
// (I changed the name, removed the defaults, and added the constraints)
//
// This controller-per-type route lets us fetch a single resource by numeric id
// It finds the appropriate method GetById method
// on the controller using WebAPI conventions
// The {id} is not optional, must be an integer, and
// must match a method with a parameter named "id" (case insensitive)
//
// ex: api/sessions/1
// ex: api/persons/1
routes.MapHttpRoute(
name: ControllerAndId,
routeTemplate: "api/{controller}/{id}",
defaults: null, //defaults: new { id = RouteParameter.Optional } //,
constraints: new {id = @"^\d+$"} // id must be all digits
);
/********************************************************
* The integer id constraint is necessary to distinguish
* the {id} route above from the {action} route below.
* For example, the route above handles
* "api/sessions/1"
* whereas the route below handles
* "api/lookups/all"
********************************************************/
// This RPC style route is great for lookups and custom calls
// It matches the {action} to a method on the controller
//
// ex: api/lookups/all
// ex: api/lookups/rooms
routes.MapHttpRoute(
name: ControllerAction,
routeTemplate: "api/{controller}/{action}"
);
//PAPA: Commented this out because we wont be using MVC views
//routes.MapRoute(
// name: "Default",
// url: "{controller}/{action}/{id}",
// defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
//);
}
开发者ID:petryxadubyk,项目名称:BaseRepository,代码行数:60,代码来源:RouteConfig.cs
示例17: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
"Throw Exception",
"ThrowException",
new { controller = "ThrowException", action = "Index" });
}
开发者ID:robertpurcell,项目名称:UmbracoSandbox,代码行数:7,代码来源:RouteConfig.cs
示例18: Routes_should_be_same_which_is_passed_in_constructor
public void Routes_should_be_same_which_is_passed_in_constructor()
{
var routes = new RouteCollection();
var registration = new RegisterRoutesBaseTestDouble(routes);
Assert.Same(routes, registration.PublicRoutes);
}
开发者ID:GTuritto,项目名称:AspNetMvcExtensibility,代码行数:7,代码来源:RegisterRoutesBaseTests.cs
示例19: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapMvcAttributeRoutes();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// 1 - Home
routes.MapRoute(null, "", new { controller = "Vitrine", action = "ListaProdutos", categoria = (string)null, pagina = 1 });
// 2 -
routes.MapRoute(null,
"Pagina{pagina}",
new { controller = "Vitrine", action = "ListaProdutos", categoria = (string)null }, new { pagina = @"\d+" });
routes.MapRoute(null,
"{categoria}", new { controller = "Vitrine", action = "ListaProdutos", pagina = 1 });
routes.MapRoute(null,
"{categoria}/Pagina{pagina}", new { controller = "Vitrine", action = "ListaProdutos" }, new { pagina = @"\d+" });
//routes.MapRoute(
// "ObterImagem",
// "Vitrine/ObterImagem/{produtoId}",
// new {controller = "Vitrine", action = "ObterImagem", produtoId = UrlParameter.Optional});
routes.MapRoute(null, "{controller}/{action}");
}
开发者ID:pauloDevrecife,项目名称:MVC_Loja,代码行数:28,代码来源:RouteConfig.cs
示例20: RequestInfo
internal RequestInfo(RouteCollection applicationRoutes, string url, string httpMethod)
{
HttpContext = TestUtility.GetHttpContext(PrepareUrl(url), httpMethod);
_applicationRoutes = applicationRoutes;
//routeData = applicationRoutes.GetRouteData(httpContext);
_requestUrl = url;
}
开发者ID:QuintSys,项目名称:Web.RouteTester.Mvc.3.0,代码行数:7,代码来源:RequestInfo.cs
注:本文中的RouteCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论