本文整理汇总了C#中IApplicationBuilder.UseSignalR方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseSignalR方法的具体用法?C# IApplicationBuilder.UseSignalR怎么用?C# IApplicationBuilder.UseSignalR使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseSignalR方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.UseFileServer();
app.UseSignalR<RawConnection>("/raw-connection");
app.UseSignalR();
}
示例2: Configure
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.UseWebSockets();
app.Use((context, next) =>
{
context.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
context.Response.Headers.Add("Access-Control-Allow-Headers", new[] { "*" });
context.Response.Headers.Add("Access-Control-Allow-Methods", new[] { "*" });
return next();
});
app.UseFileServer();
app.UseSignalR<RawConnection>("/raw-connection");
app.UseSignalR();
}
示例3: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Add static files to the request pipeline
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline
app.UseIdentity();
// Add the following to the request pipeline only in development environment.
if (env.IsEnvironment("Development"))
{
app.UseBrowserLink();
}
/* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
* Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
*/
app.UseErrorPage(ErrorPageOptions.ShowAll);
app.ConfigureSecurity();
//Configure SignalR
app.UseSignalR();
// Add MVC to the request pipeline
app.ConfigureRoutes();
MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();
}
示例4: Configure
public void Configure(IApplicationBuilder app) {
app.UseDefaultFiles();
app.UseStaticFiles();
// Add a new middleware validating access tokens.
app.UseOAuthValidation(options => {
options.Events = new OAuthValidationEvents {
// Note: for SignalR connections, the default Authorization header does not work,
// because the WebSockets JS API doesn't allow setting custom parameters.
// To work around this limitation, the access token is retrieved from the query string.
OnRetrieveToken = context => {
context.Token = context.Request.Query["access_token"];
return Task.FromResult(0);
}
};
});
app.UseSignalR<SimpleConnection>("/signalr");
// Add a new middleware issuing access tokens.
app.UseOpenIdConnectServer(options => {
options.Provider = new AuthenticationProvider();
// Enable the token endpoint.
options.TokenEndpointPath = "/connect/token";
options.AllowInsecureHttp = true;
});
}
示例5: Configure
public void Configure(IApplicationBuilder app)
{
/* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
* Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
*/
app.UseErrorPage(ErrorPageOptions.ShowAll);
//Configure SignalR
app.UseSignalR();
//Serves static files in the application.
app.UseFileServer();
//Configure WebFx
app.UseMvc(routes =>
{
routes.MapRoute(
null,
"{controller}/{action}",
new { controller = "Home", action = "Index" });
routes.MapRoute(
null,
"api/{controller}/{action}",
new { controller = "Home", action = "Index" });
routes.MapRoute(
null,
"api/{controller}",
new { controller = "Home" });
});
}
示例6: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.ApplicationServices
.GetService<Db>()
.Database
.EnsureCreated();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseSignalR();
app.UseMvc(routes => { routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); });
}
示例7: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseSignalR();
}
示例8: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// Setup configuration sources. May be unnecessary
var builder = new ConfigurationBuilder().SetBasePath(env.ContentRootPath).AddJsonFile("appsettings.json").AddEnvironmentVariables(); ;
Configuration = builder.Build();
loggerFactory.AddConsole();
serviceHelpers.rootPath = env.ContentRootPath;
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseExceptionHandler("/Home/Error");
app.UseStaticFiles();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{player?}",
defaults: new { controller = "Player", action = "Index" }
);
routes.MapRoute(
name: "Robot",
template: "{controller}/{action}/{bot?}"
);
});
app.UseFileServer();
app.UseSignalR();
}
示例9: Configure
public void Configure(IApplicationBuilder app)
{
// Setup configuration sources
var configuration = new Configuration();
configuration.AddJsonFile("config.json");
configuration.AddEnvironmentVariables();
// Set up application services
app.UseServices(services =>
{
// Add EF services to the services container and configure DbContext
services.ConfigureDataContext(configuration);
// Register MyShuttle dependencies
services.ConfigureDependencies();
//Add Identity services to the services container
services.AddDefaultIdentity<MyShuttleContext, ApplicationUser, IdentityRole>(configuration);
services.ConfigureCookieAuthentication(options =>
{
options.LoginPath = new Microsoft.AspNet.Http.PathString("/Carrier/Login");
});
// Add MVC services to the services container
services.AddMvc();
services
.AddSignalR(options =>
{
options.Hubs.EnableDetailedErrors = true;
});
});
// Enable Browser Link support
app.UseBrowserLink();
/* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
* Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
*/
app.UseErrorPage(ErrorPageOptions.ShowAll);
// Add static files to the request pipeline
app.UseStaticFiles();
app.ConfigureSecurity();
//Configure SignalR
app.UseSignalR();
// Add cookie-based authentication to the request pipeline
// Add MVC to the request pipeline
app.ConfigureRoutes();
MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();
}
示例10: Configure
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
#if DNX451
string OutputTemplate = "{SourceContext} {Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}";
var serilog = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.RollingFile(@".\SignalR-Log-{Date}.txt", outputTemplate: OutputTemplate);
loggerFactory.AddSerilog(serilog);
#endif
app.UseFileServer();
app.UseSignalR<RawConnection>("/raw-connection");
app.UseSignalR();
}
示例11: Configure
public void Configure(IApplicationBuilder app)
{
app.UseSignalR();
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}
示例12: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Configure the HTTP request pipeline.
app.UseStaticFiles();
// Add MVC to the request pipeline.
app.UseMvc();
app.UseSignalR();
}
示例13: Configure
public void Configure(IApplicationBuilder app)
{
app.UseGlimpse();
// TODO: Nedd to find a better way of registering this. Problem is that this
// registration is aspnet5 specific.
app.UseSignalR("/Glimpse/Data/Stream");
app.UseWelcomePage();
}
示例14: Configure
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
app.UseSignalR();
app.Run(async (context) =>
{
context.Response.ContentType = "text/html";
await context.Response.SendFileAsync("index.html");
});
}
示例15: Configure
public void Configure(IApplicationBuilder app)
{
// Configure SignalR
app.UseSignalR();
// Add static files to the request pipeline
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline
app.UseIdentity();
////app.UseFacebookAuthentication();
////app.UseGoogleAuthentication();
////app.UseTwitterAuthentication();
// The MicrosoftAccount service has restrictions that prevent the use of http://localhost:5001/ for test applications.
// As such, here is how to change this sample to uses http://ktesting.com:5001/ instead.
// Edit the Project.json file and replace http://localhost:5001/ with http://ktesting.com:5001/.
// From an admin command console first enter:
// notepad C:\Windows\System32\drivers\etc\hosts
// and add this to the file, save, and exit (and reboot?):
// 127.0.0.1 ktesting.com
// Then you can choose to run the app as admin (see below) or add the following ACL as admin:
// netsh http add urlacl url=http://ktesting:5001/ user=[domain\user]
// The sample app can then be run via:
// k web
////app.UseMicrosoftAccountAuthentication();
// Add MVC to the request pipeline
app.UseMvc(routes =>
{
routes.MapRoute(
name: "areaRoute",
template: "{area:exists}/{controller}/{action}",
defaults: new { action = "Index" });
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
routes.MapRoute(
name: "api",
template: "{controller}/{id?}");
});
//Populates the OpenLan sample data
SampleData.InitializeOpenLanDatabaseAsync(app.ApplicationServices).Wait();
}