本文整理汇总了C#中IAppBuilder.UseHandler方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseHandler方法的具体用法?C# IAppBuilder.UseHandler怎么用?C# IAppBuilder.UseHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppBuilder
的用法示例。
在下文中一共展示了IAppBuilder.UseHandler方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configuration
public void Configuration(IAppBuilder app)
{
app.UseHandler(async (request, response) => {
response.ContentType = "text/html";
await response.WriteAsync("OWIN Hello World!!");
});
}
示例2: Configuration
public void Configuration(IAppBuilder builder)
{
builder.UseHandler((request, response) =>
{
// write headers first!
response.StatusCode = 200;
response.Write("Sup");
});
}
示例3: Configuration
public void Configuration(IAppBuilder app)
{
var logger = app.CreateLogger(GetType());
app.SetDataProtectionProvider(new SharedSecretDataProtectionProvider(
"af98j3pf98ja3fdopa32hr !!!! DO NOT USE THIS STRING IN YOUR APP !!!!",
"AES",
"HMACSHA256"));
// example of a filter - writeline each request
app.UseFilter(req => logger.WriteInformation(string.Format(
"{0} {1}{2} {3}",
req.Method,
req.PathBase,
req.Path,
req.QueryString)));
// example of a handler - all paths reply Hello, Owin!
app.UseHandler(async (req, res) =>
{
res.ContentType = "text/plain";
await res.WriteAsync("Hello, OWIN!");
});
}
示例4: Configuration
public void Configuration(IAppBuilder builder)
{
builder.UseHandler((request, response) => response.Write(_myService.GetFoo()));
}
示例5: Configuration1
public void Configuration1(IAppBuilder builder)
{
builder.UseHandler((request, response) => response.Write("Sup"));
}
示例6: Configuration
public void Configuration(IAppBuilder builder)
{
builder.UseHandler((request, response) => response.StatusCode = 404);
}