本文整理汇总了C#中IAppBuilder.UseNancy方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseNancy方法的具体用法?C# IAppBuilder.UseNancy怎么用?C# IAppBuilder.UseNancy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAppBuilder
的用法示例。
在下文中一共展示了IAppBuilder.UseNancy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configuration
public void Configuration(IAppBuilder app)
{
app.Use((ctx, next) =>
{
var output = ctx.Get<TextWriter>("host.TraceOutput");
output.WriteLine("{0} {1}: {2}", ctx.Request.Scheme, ctx.Request.Method, ctx.Request.Path);
return next();
});
GlobalHost.DependencyResolver.Register(typeof(VoteHub),
() => new VoteHub(new QuestionRepository()));
app.UseStaticFiles();
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
//app.MapSignalR();
app.Map("/signalr", map => map.UseCors(CorsOptions.Value)
.RunSignalR(new HubConfiguration
{
EnableJSONP = true
}));
app.UseNancy(options =>
options.PerformPassThrough = context =>
context.Response.StatusCode == HttpStatusCode.NotFound);
app.Run(context =>
{
context.Response.ContentType = "text/plain";
return context.Response.WriteAsync("Hello World!");
});
}
示例2: Configuration
public void Configuration(IAppBuilder app)
{
if (SetNancyFlag(app))
{
app.UseNancy();
}
}
示例3: Configuration
public void Configuration(IAppBuilder app)
{
var option = new NancyOptions
{
Bootstrapper = new Bootstrapper(),
PerformPassThrough = context =>
context.Response.StatusCode == HttpStatusCode.NotFound
};
//option.PassThroughWhenStatusCodesAre(HttpStatusCode.ServiceUnavailable);
app.UseNancy(option);
//app.UseNancy();
app.Map("/core",
coreApp =>
{
coreApp.UseIdentityServer(new IdentityServerOptions
{
SiteName = "Standalone Identity Server",
SigningCertificate = Certificate.Get(),
Factory = new IdentityServerServiceFactory()
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(Scopes.Get())
.UseInMemoryUsers(Users.Get())
});
});
}
示例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: 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);
}
示例6: Configuration
public void Configuration(IAppBuilder app)
{
app.UseNancy(x =>
{
x.Bootstrapper = new CustomConventionsNancy();
});
}
示例7: Configuration
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
// Static file support.
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
app.UseStaticFiles(new StaticFileOptions
{
FileSystem = new PhysicalFileSystem(root: baseDir),
ServeUnknownFileTypes = false
});
// ASP.NET Web API support.
var config = new HttpConfiguration();
// Fix: CORS support of WebAPI doesn't work on mono. http://stackoverflow.com/questions/31590869/web-api-2-post-request-not-working-on-mono
if (Type.GetType("Mono.Runtime") != null) config.MessageHandlers.Add(new MonoPatchingDelegatingHandler());
config.EnableCors();
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
app.UseWebApi(config);
// NancyFx support.
app.UseNancy();
}
示例8: Configuration
public void Configuration(IAppBuilder app)
{
Common.Setup.AutoMapper.Initialize();
app.MapSignalR();
app.UseNancy();
app.UseStageMarker(PipelineStage.MapHandler);
}
示例9: Configuration
public void Configuration(IAppBuilder appBuilder)
{
// Host all the WebAPI components underneath a path so we can
// easily deploy a traditional site at the root of the web
// application
//
appBuilder.Map("/api", api =>
{
// This object is what we use to configure the behavior
// of WebAPI in our application
//
var httpConfiguration = new HttpConfiguration();
// We'll use attribute based routing instead of the
// convention-based approach
//
httpConfiguration.MapHttpAttributeRoutes();
// Change the serialization so it does camelCase
//
var jsonFormatter = httpConfiguration.Formatters.JsonFormatter;
var settings = jsonFormatter.SerializerSettings;
settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
// Now add in web api to the OWIN pipeline
//
api.UseWebApi(httpConfiguration);
});
// Add nancy to the pipeline after WebAPI so the API can
// handle any requests it is configured for first
//
appBuilder.UseNancy();
}
示例10: Configuration
public void Configuration(IAppBuilder app)
{
app.UseNancy(options =>
{
options.Bootstrapper = new Bootstrapper();
});
}
示例11: Configuration
public void Configuration(IAppBuilder app)
{
app.UseNancy(new Nancy.Owin.NancyOptions
{
Bootstrapper = new DefaultNancyBootstrapper()
});
}
示例12: Configuration
// This code configures Web API. The Startup class is specified as a type
// parameter in the WebApp.Start method.
//
public void Configuration(IAppBuilder appBuilder)
{
// We're going to hang the web API off off the /api "sub"-url so that we
// leave the root url open for the Angular 2 website.
//
appBuilder.Map("/api", api =>
{
// Create our config object we'll use to configure the API
//
var config = new HttpConfiguration();
// Use attribute routing
//
config.MapHttpAttributeRoutes();
// Now add in the WebAPI middleware
//
api.UseWebApi(config);
});
// Add Nancy to the OWIN pipeline.
// Note, because this is registered last we don't need to worry
// about falling-through to any other middleware. Any requests to
// /api/... will be handled by WebAPI first, and anything else
// will fall through to Nancy
//
appBuilder.UseNancy();
}
示例13: 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
}
示例14: Configure
public static void Configure(IAppBuilder app, IContainer container)
{
var webConfiguration = new WebConfiguration();
string absolutePath = null;
if (webConfiguration.NancyViewPath != null)
{
var isPathRooted = Path.IsPathRooted(webConfiguration.NancyViewPath);
if (isPathRooted)
{
absolutePath = webConfiguration.NancyViewPath;
}
else
{
var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
absolutePath = Path.Combine(baseDirectory, webConfiguration.NancyViewPath);
absolutePath = Path.GetFullPath(absolutePath);
}
}
AutofacNancyBootstrapper.RootPath = absolutePath;
AutofacNancyBootstrapper.Container = container;
app.UseNancy(new NancyOptions
{
PerformPassThrough = context => context.Response.StatusCode == HttpStatusCode.NotFound
});
}
示例15: Configuration
public void Configuration(IAppBuilder app)
{
InitDb();
app.ConfigureMembershipReboot();
app.UseNancy();
}