本文整理汇总了C#中IAppBuilder.UseStageMarker方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseStageMarker方法的具体用法?C# IAppBuilder.UseStageMarker怎么用?C# IAppBuilder.UseStageMarker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppBuilder
的用法示例。
在下文中一共展示了IAppBuilder.UseStageMarker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configuration
/// <summary>
/// The Startup configuration sets up a pipeline with three middleware components, the first two displaying diagnostic information
/// and the last one responding to events (and also displaying diagnostic information). The PrintCurrentIntegratedPipelineStage
/// method displays the integrated pipeline event this middleware is invoked on and a message.
/// </summary>
public void Configuration(IAppBuilder app)
{
app.Use((context, next) =>
{
PrintCurrentIntegratedPipelineStage(context, "Middleware 1");
return next.Invoke();
});
app.Use((context, next) =>
{
PrintCurrentIntegratedPipelineStage(context, "2nd MW");
return next.Invoke();
});
// You can mark OMCs to execute at specific stages of the pipeline by using the IAppBuilder UseStageMarker() extension method.
// To run a set of middleware components during a particular stage, insert a stage marker right after the last component is the set
// during registration. There are rules on which stage of the pipeline you can execute middleware and the order components must run
// (The rules are explained later in the tutorial). Add the UseStageMarker method to the Configuration code as shown below:
app.UseStageMarker(PipelineStage.Authenticate);
app.Run(context =>
{
PrintCurrentIntegratedPipelineStage(context, "3rd MW");
return context.Response.WriteAsync("Hello world");
});
app.UseStageMarker(PipelineStage.ResolveCache);
}
示例2: Start
protected virtual void Start(IAppBuilder app, IContainer container)
{
var config = CreateHttpConfiguration();
ConfigureWebApi(config, container);
if (Settings.ShowExceptionDetails)
{
app.UseErrorPage(new ErrorPageOptions
{
ShowExceptionDetails = true,
ShowSourceCode = true
});
}
app.UseAutofacMiddleware(container);
app.UseStageMarker(PipelineStage.Authenticate);
app.UseAutofacWebApi(config);
app.UseWebApi(config);
RegisterSignalR(container, app);
app.UseStageMarker(PipelineStage.MapHandler);
RegisterServices(container, app, config);
RegisterShutdown(app, container);
StartIndexingIfConfigured(container);
}
示例3: Configuration
/// <summary>
/// OWIN start up method
/// </summary>
/// <param name="app">The app.</param>
public void Configuration(IAppBuilder app)
{
var config = new System.Web.Http.HttpConfiguration();
app.Use((context, next) =>
{
return next.Invoke();
});
app.UseStageMarker(PipelineStage.Authenticate);
Swashbuckle.Bootstrapper.Init(config);
WebApiConfig.Register(config);
app.UseWebApi(config);
app.UseStageMarker(PipelineStage.MapHandler);
}
示例4: Configuration
public void Configuration(IAppBuilder app)
{
ConfigureLogger();
var builder = new ContainerBuilder();
builder.RegisterLogger();
builder.RegisterByAttributes(typeof (Startup).Assembly);
builder.RegisterAssemblyModules(typeof (Startup).Assembly);
builder.RegisterHubs(typeof (Startup).Assembly);
var container = builder.Build();
// config hubs
var config = new HubConfiguration();
config.Resolver = new AutofacDependencyResolver(container);
app.UseJwtTokenAuthentication(container.Resolve<IssuerSetting>(),
container.Resolve<AudienceSetting>(),
container.Resolve<ClientSecretSetting>(),
container.Resolve<ICurrentUserProvider>());
app.MapSignalR(config);
app.UseNancy(new NancyOptions
{
Bootstrapper = new NancyBootstrapper(container)
});
app.UseStageMarker(PipelineStage.MapHandler);
app.UseCors(CorsOptions.AllowAll);
JsonSettings.RetainCasing = false;
SeedData(container);
}
示例5: MiddlewaresAtDifferentStagesConfiguration
public void MiddlewaresAtDifferentStagesConfiguration(IAppBuilder app)
{
app.Use((context, next) =>
{
//Create a custom object in the dictionary to push middlewareIds.
context.Set<Stack<int>>("stack", new Stack<int>());
return next.Invoke();
});
var stageTuples = new Tuple<RequestNotification, PipelineStage>[]
{
new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthenticateRequest, PipelineStage.Authenticate),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthenticateRequest, PipelineStage.PostAuthenticate),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthorizeRequest, PipelineStage.Authorize),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.AuthorizeRequest, PipelineStage.PostAuthorize),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.ResolveRequestCache, PipelineStage.ResolveCache),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.ResolveRequestCache, PipelineStage.PostResolveCache),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.MapRequestHandler, PipelineStage.MapHandler),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.MapRequestHandler, PipelineStage.PostMapHandler),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.AcquireRequestState, PipelineStage.AcquireState),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.AcquireRequestState, PipelineStage.PostAcquireState),
new Tuple<RequestNotification, PipelineStage>(RequestNotification.PreExecuteRequestHandler, PipelineStage.PreHandlerExecute),
};
for (int middlewareId = 0; middlewareId < stageTuples.Length; middlewareId++)
{
var stage = stageTuples[middlewareId];
app.Use<IntegratedPipelineMiddleware>(stage.Item1, middlewareId);
app.UseStageMarker(stage.Item2);
}
}
示例6: Configuration
public void Configuration(IAppBuilder app)
{
var httpConfiguration = new HttpConfiguration();
// Configure Web API Routes:
// - Enable Attribute Mapping
// - Enable Default routes at /api.
httpConfiguration.MapHttpAttributeRoutes();
httpConfiguration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
app.UseWebApi(httpConfiguration);
// Make ./public the default root of the static files in our Web Application.
app.UseFileServer(new FileServerOptions
{
RequestPath = new PathString(string.Empty),
FileSystem = new PhysicalFileSystem("./public"),
EnableDirectoryBrowsing = true,
});
app.UseStageMarker(PipelineStage.MapHandler);
}
示例7: Configuration
public void Configuration(IAppBuilder app)
{
var httpConfiguration = new HttpConfiguration();
// set response formatters
httpConfiguration.Formatters.Clear();
SetWebApiResponseAsJson(httpConfiguration);
// Configure Web API Routes:
// - Enable Attribute Mapping
// - Enable Default routes at /api.
httpConfiguration.MapHttpAttributeRoutes();
httpConfiguration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}"
);
httpConfiguration.Routes.MapHttpRoute(
name: "Default",
routeTemplate: "r/{hashId}",
defaults: new { controller = "RedirectUrl" }
);
app.UseWebApi(httpConfiguration);
// Make ./public the default root of the static files in our Web Application.
app.UseFileServer(new FileServerOptions
{
RequestPath = new PathString(string.Empty),
FileSystem = new PhysicalFileSystem("./App/www"),
EnableDirectoryBrowsing = true,
});
app.UseStageMarker(PipelineStage.MapHandler);
}
示例8: DefaultStaticFiles
public void DefaultStaticFiles(IAppBuilder app)
{
app.Use((context, next) => { context.Response.Headers["PassedThroughOWIN"] = "True"; return next(); });
app.UseStaticFiles();
app.Run(context => { context.Response.StatusCode = 402; return context.Response.WriteAsync("Fell Through"); });
app.UseStageMarker(PipelineStage.MapHandler);
}
示例9: Configuration
public void Configuration(IAppBuilder app)
{
#if DEBUG
//when things go south
app.UseErrorPage();
#endif
FileServerOptions fileServerOptions = new FileServerOptions()
{
RequestPath = PathString.Empty,
FileSystem = new PhysicalFileSystem(@".\\public"),
};
//In order to serve json files
fileServerOptions.StaticFileOptions.ServeUnknownFileTypes = true;
fileServerOptions.StaticFileOptions.DefaultContentType = "text";
// Remap '/' to '.\public\'.
// Turns on static files and public files.
app.UseFileServer(fileServerOptions);
app.UseStageMarker(PipelineStage.MapHandler);
//Web Api
HttpConfiguration config = new HttpConfiguration();
config.MapHttpAttributeRoutes();
//Cause all the cool kids use JSON
config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
config.Formatters.Remove(config.Formatters.XmlFormatter);
app.UseWebApi(config);
}
示例10: Configuration
public void Configuration(IAppBuilder app)
{
app.UseNancy();
// todo: uncomment to invoke non-default Bootstrapper ctor
//app.UseNancy(new NancyOptions() { Bootstrapper = new CustomBootstrapper(str: "hi") });
app.UseStageMarker(PipelineStage.MapHandler);//required to display Nancy assets on IIS
}
示例11: Configuration
public void Configuration(IAppBuilder app)
{
JwtSecurityTokenHandler.InboundClaimTypeMap.Clear();
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "https://localhost:44333/core",
RequiredScopes = new[] { "api" },
NameClaimType = "name",
RoleClaimType = "role",
// client credentials for the introspection endpoint
ClientId = "angularMaterial",
ClientSecret = Guid.NewGuid().ToString()
});
var configuration = new HttpConfiguration();
configuration.MapHttpAttributeRoutes();
var jsonFormatter = configuration.Formatters.OfType<JsonMediaTypeFormatter>().FirstOrDefault();
if (jsonFormatter != null)
{
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
}
app.UseResourceAuthorization(new AuthorizationManager());
app.UseWebApi(configuration);
app.UseNancy();
app.UseStageMarker(PipelineStage.MapHandler);
}
示例12: Configuration
public void Configuration(IAppBuilder app)
{
Common.Setup.AutoMapper.Initialize();
app.MapSignalR();
app.UseNancy();
app.UseStageMarker(PipelineStage.MapHandler);
}
示例13: Configuration
public void Configuration(IAppBuilder app)
{
/* // Note: Enable only for debugging. This slows down the perf tests.
app.Use((context, next) =>
{
var req = context.Request;
context.TraceOutput.WriteLine("{0} {1}{2} {3}", req.Method, req.PathBase, req.Path, req.QueryString);
return next();
});*/
app.UseErrorPage(new ErrorPageOptions { SourceCodeLineCount = 20 });
// app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
app.UseSendFileFallback();
app.Use<CanonicalRequestPatterns>();
app.UseStaticFiles(new StaticFileOptions()
{
RequestPath = new PathString("/static"),
FileSystem = new PhysicalFileSystem("public")
});
app.UseDirectoryBrowser(new DirectoryBrowserOptions()
{
RequestPath = new PathString("/static"),
FileSystem = new PhysicalFileSystem("public")
});
app.UseStageMarker(PipelineStage.MapHandler);
FileServerOptions options = new FileServerOptions();
options.EnableDirectoryBrowsing = true;
options.StaticFileOptions.ServeUnknownFileTypes = true;
app.UseWelcomePage("/Welcome");
}
示例14: Configuration
public void Configuration(IAppBuilder app)
{
var httpConfiguration = new HttpConfiguration();
// Configure Web API Routes:
// - Enable Attribute Mapping
// - Enable Default routes at /api.
httpConfiguration.MapHttpAttributeRoutes();
httpConfiguration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
httpConfiguration.Formatters.Clear();
httpConfiguration.Formatters.Add(new JsonMediaTypeFormatter());
httpConfiguration.Formatters.JsonFormatter.SerializerSettings =
new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
app.UseWebApi(httpConfiguration);
// Make ./public the default root of the static files in our Web Application.
app.UseFileServer(new FileServerOptions
{
RequestPath = new PathString(string.Empty),
FileSystem = new PhysicalFileSystem("./"),
EnableDirectoryBrowsing = true,
});
app.UseStageMarker(PipelineStage.MapHandler);
}
示例15: Configuration
public void Configuration(IAppBuilder app)
{
var builder = new ContainerBuilder();
builder.RegisterAssemblyModules(GetType().Assembly);
var container = builder.Build();
app.Use(typeof(StubJwtBearerAuthenticationMiddleware), app, new StubJwtBearerAuthenticationOptions("jwt"));
app.UseStageMarker(PipelineStage.Authenticate);
app.UseNancy(options =>
{
var bootstrapper = new FlogNancyBootstrapper()
.UseContainer(container);
options.Bootstrapper = bootstrapper;
});
app.UseStageMarker(PipelineStage.MapHandler);
}