本文整理汇总了C#中RouteCollection.MapServiceRoute方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.MapServiceRoute方法的具体用法?C# RouteCollection.MapServiceRoute怎么用?C# RouteCollection.MapServiceRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.MapServiceRoute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapServiceRoute<HypermediaAPI.RootController>("");
routes.MapServiceRoute<HypermediaAPI.Login.LoginController>("Login");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例2: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapServiceRoute<GameService>("game");
routes.MapServiceRoute<AuthService>("auth");
routes.MapServiceRoute<UserService>("user");
routes.MapServiceRoute<EventService>("event");
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional });
}
示例3: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
var config = new WebApiConfiguration { EnableTestClient = true };
config.ErrorHandlers = OnErrorHandlers;
if (UseHttpContextForStoringUniqueRequestId)
{
config.MessageHandlerFactory = () => new List<DelegatingHandler> { new HttpContextRequestIdHandler() };
}
else
{
config.MessageHandlerFactory = () => new List<DelegatingHandler> { new OperationContextRequestIdHandler() };
}
routes.SetDefaultHttpConfiguration(config);
routes.MapServiceRoute<StringService>("api/str");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例4: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
ContainerBuilder builder = new ContainerBuilder();
Action<MappingConfiguration> mappingsConfig = mappings=>mappings.FluentMappings.AddFromAssemblyOf<NosSessionMap>();
builder.Register<INHibernateSessionProvider, SqlServerConnectionStringNHibernateSessionProvider>().WithArguments(
"nosplanner", mappingsConfig).ControlledBy<SingletonLifecycle>();
builder.Register<INosSessionRepository, NosSessionRepository>().ControlledBy<SingletonLifecycle>();
builder.Register<IAttendeeRepository, AttendeeRepository>().ControlledBy<SingletonLifecycle>();
IContainer container = builder.Build();
var configuration =
HttpHostConfiguration
.Create()
.SetResourceFactory((serviceType, instanceContext, request) => container.Resolve(serviceType), null)
.SetErrorHandler<ContactManagerErrorHandler>();
routes.MapServiceRoute<SessionsResource>("sessions", configuration);
routes.MapServiceRoute<SessionResource>("session", configuration);
routes.MapServiceRoute<AttendeesResource>("attendees",configuration);
}
示例5: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapServiceRoute<BlogEngineService>("blog");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例6: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new { controller = "^(?!SignupSvc).*" }
);
var bldr = HttpHostConfiguration.Create().SetOperationHandlerFactory(new JsonOnlyFactory());
routes.MapServiceRoute<SignupSvc>("SignupSvc", bldr);
}
示例7: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// configure api service
var config = new HttpConfiguration() { EnableTestClient = true };
routes.MapServiceRoute<ContactsApi>("api/contacts", config);
// configure mvc controllers
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例8: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
var config = new WebApiConfiguration() {EnableTestClient = true, EnableHelpPage = true};
routes.SetDefaultHttpConfiguration(config);
routes.MapServiceRoute<ExpeditionApi>("api/expvar");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例9: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// Custom configuration which enables the structuremap integaration
// via create/release instance methods.
var config = new ApiConfiguration() { EnableTestClient = true };
routes.SetDefaultHttpConfiguration(config);
routes.MapServiceRoute<ContactsApi>("api/contacts");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例10: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
new { controller = ServiceContracts.In(Assembly.GetExecutingAssembly()).WithDefaultConverter() }
);
var configurationBuilder = HttpHostConfiguration.Create()
.SetMessageHandlerFactory(new CustomHttpMessageChannelFactory())
.SetOperationHandlerFactory(new CustomHttpOperationHandlerFactory());
routes.MapServiceRoute<DateTimeService>(configurationBuilder);
}
示例11: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
var config = new HttpConfiguration();
config.EnableTestClient = true;
config.MessageHandlers.Add(typeof(LoggingHandler));
config.ErrorHandlers = delegate { new ExceptionErrorHandler(); };
routes.SetDefaultHttpConfiguration(config);
routes.MapServiceRoute<ContactsApi>("api/contacts");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例12: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
HttpConfiguration configuration = new WebApiConfiguration();// {EnableTestClient = true};
configuration.Formatters.Add(new JpgFormatter());
configuration.Formatters.Add(new RssFormatter());
configuration.MessageHandlers.Add(typeof(UriFormatHandler));
#if DEBUG
configuration.EnableTestClient = true;
#endif
routes.MapServiceRoute<DonaldApi>("api/donald", configuration);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例13: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapServiceRoute<AtomFeedService>("Feed", new AtomFeedHttpConfiguration());
routes.MapRoute(
"Index", // Route name
"blogs", // URL with parameters
new { controller = "Blogs", action = "Index"} // Parameter defaults
);
routes.MapRoute(
"Create", // Route name
"blogs/create", // URL with parameters
new { controller = "Blogs", action = "Create"} // Parameter defaults
);
routes.MapRoute(
"Edit", // Route name
"blogs/{id}/edit", // URL with parameters
new { controller = "Blogs", action = "Edit"} // Parameter defaults
);
routes.MapRoute(
"Delete", // Route name
"blogs/{id}/delete", // URL with parameters
new { controller = "Blogs", action = "Delete"} // Parameter defaults
);
routes.MapRoute(
"Details", // Route name
"blogs/{id}", // URL with parameters
new { controller = "Blogs", action = "Details"} // Parameter defaults
);
routes.MapRoute(
"Posts", // Route name
"blogs/{blogId}/posts", // URL with parameters
new { controller = "Posts", action = "Index" } // Parameter defaults
);
routes.MapRoute(
"CreatePost", // Route name
"blogs/{blogId}/posts/create", // URL with parameters
new { controller = "Posts", action = "Create" } // Parameter defaults
);
routes.MapRoute(
"PostEdit", // Route name
"blogs/{blogId}/posts/{id}/edit", // URL with parameters
new { controller = "Posts", action = "Edit" } // Parameter defaults
);
routes.MapRoute(
"PostDelete", // Route name
"blogs/{blogId}/posts/{id}/delete", // URL with parameters
new { controller = "Posts", action = "Delete" } // Parameter defaults
);
routes.MapRoute(
"PostDetails", // Route name
"blogs/{blogId}/posts/{id}", // URL with parameters
new { controller = "Posts", action = "Details" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"", // URL with parameters
new { controller = "Home", action = "Index"} // Parameter defaults
);
routes.MapRoute(
"All", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
示例14: RegisterServiceRoutes
// note: Pulled out service route registration separately because it's not testable T.T (won't run outside IIS/WAS)
public static void RegisterServiceRoutes(RouteCollection routes)
{
routes.MapServiceRoute(
RouteName.V1ApiFeed,
"api/v1/FeedService.svc",
typeof(V1Feed));
routes.MapServiceRoute(
"LegacyFeedService",
"v1/FeedService.svc",
typeof(V1Feed));
routes.MapServiceRoute(
"v1" + RouteName.V1ApiFeed,
"api/v1",
typeof(V1Feed));
routes.MapServiceRoute(
RouteName.V2ApiCuratedFeed,
"api/v2/curated-feed",
typeof(V2CuratedFeed));
routes.MapServiceRoute(
RouteName.V2ApiFeed,
"api/v2/",
typeof(V2Feed));
}
示例15: RegisterRoutes
//.........这里部分代码省略.........
routes.MapRoute(
RouteName.PasswordReset,
"account/{action}/{username}/{token}",
MVC.Users.ResetPassword());
routes.MapRoute(
RouteName.Account,
"account/{action}",
MVC.Users.Account());
routes.MapRoute(
RouteName.CuratedFeed,
"curated-feeds/{name}",
new { controller = CuratedFeedsController.ControllerName, action = "CuratedFeed" });
routes.MapRoute(
RouteName.CreateCuratedPackageForm,
"forms/add-package-to-curated-feed",
new { controller = CuratedPackagesController.ControllerName, action = "CreateCuratedPackageForm" });
routes.MapRoute(
RouteName.CuratedPackage,
"curated-feeds/{curatedFeedName}/curated-packages/{curatedPackageId}",
new { controller = CuratedPackagesController.ControllerName, action = "CuratedPackage" });
routes.MapRoute(
RouteName.CuratedPackages,
"curated-feeds/{curatedFeedName}/curated-packages",
new { controller = CuratedPackagesController.ControllerName, action = "CuratedPackages" });
// TODO : Most of the routes are essentially of the format api/v{x}/*. We should refactor the code to vary them by the version.
// V1 Routes
// If the push url is /api/v1 then NuGet.Core would ping the path to resolve redirection.
routes.MapServiceRoute(
RouteName.V1ApiFeed,
"api/v1/FeedService.svc",
typeof(V1Feed));
routes.MapServiceRoute(
"LegacyFeedService",
"v1/FeedService.svc",
typeof(V1Feed));
routes.MapRoute(
"v1" + RouteName.VerifyPackageKey,
"api/v1/verifykey/{id}/{version}",
MVC.Api.VerifyPackageKey(),
defaults: new { id = UrlParameter.Optional, version = UrlParameter.Optional });
var downloadRoute = routes.MapRoute(
"v1" + RouteName.DownloadPackage,
"api/v1/package/{id}/{version}",
MVC.Api.GetPackage(),
defaults: new { version = UrlParameter.Optional },
constraints: new { httpMethod = new HttpMethodConstraint("GET") });
routes.MapRoute(
"site" + RouteName.DownloadPackage,
"packages/{id}/{version}/DownloadPackage",
MVC.Api.GetPackage(),
defaults: new { version = UrlParameter.Optional },
constraints: new { httpMethod = new HttpMethodConstraint("GET") });
routes.MapRoute(
"v1" + RouteName.PushPackageApi,
"v1/PackageFiles/{apiKey}/nupkg",