public static IRouteTable AddFileRoute(this IRouteTable routeTable, string urlPath, string filename, Func<OwinRequest, object> modelProvider) { if (routeTable == null) { throw new ArgumentNullException("routeTable"); } if (modelProvider == null) { throw new ArgumentNullException("modelProvider"); } if (string.IsNullOrWhiteSpace(urlPath)) { throw new ArgumentNullException("urlPath"); } if (string.IsNullOrWhiteSpace(filename)) { throw new ArgumentNullException("filename"); } IFileInfo fileInfo; if (!routeTable.FileSystem.TryGetFileInfo(filename, out fileInfo)) { throw new IOException(string.Format(CultureInfo.CurrentCulture, "File '{0}' was not found.", filename)); } var handler = new SimpleRequestHandler(fileInfo, modelProvider); var route = new SingleFileRoute(urlPath, handler); return routeTable.AddRoute(route); }
public static void AddDefaultRoute(this HttpRequestMessage request) { request.RequestUri = new Uri(request.RequestUri, "api/Home"); request.AddRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); }
public static Route MapASPxPageRoute(this RouteCollection source, string routeName, string routeUrl, string physicalFile, string notFoundFile, RouteValueDictionary defaults, RouteValueDictionary constraints) { var actualRouteUrl = routeUrl; var actualDefaults = PERMANENT_DEFAULTS.ExcludeUnusedIn(actualRouteUrl).MergeWith(defaults).ExcludeNull(); var actualConstraints = PERMANENT_CONSTRAINTS.ExcludeUnusedIn(actualRouteUrl).MergeWith(constraints).ExcludeNull(); var actualRouteHandler = new ASPxPageCustomRouteHandler(physicalFile, notFoundFile); return source.AddRoute( routeName, new Route( actualRouteUrl, actualDefaults, actualConstraints, actualRouteHandler ) ); }
public static IHttpRoute AddDefaultRoute(this HttpConfiguration configuration) { return configuration.AddRoute("Default", "api/{controller}/{id}", new { id = RouteParameter.Optional }); }