大佬教程收集整理的这篇文章主要介绍了ASP.Net Core SignalR - 在启动类之外访问 IApaplicationBuilder 以调用 MapHub 方法,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个用例,我正在尝试创建可以由我组织中的各种应用程序使用的 SignalR 服务器库。
SignalR 库有两个主要类
公共类 SignalRHost { 公共无效开始(字符串网址) { CreateHostBuilder(url).build().Run(); }
public static IWebHostBuilder CreateHostBuilder(String url) =>
WebHost.CreateDefaultBuilder().UseStartup<Startup>().UseUrls(url);
public voID MapHub<T>(String pattern) where T : Hub
{
// I want to have a method which a clIEnt code calls to Map its Hub
// It need reference of IApplicationBuilder + at what instance i can call this
}
}
公开课启动 { 公共启动(IConfiguration配置) { 配置=配置; }
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public voID Configureservices(IserviceCollection services)
{
//services.AddRazorPages();
services.AddSignalR();
}
// This method gets called by the runtime. Use this method to configure the http request pipeline.
public voID Configure(IApplicationBuilder app,IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios,see https://aka.ms/aspnetcore-hsts.
//app.UseHsts();
}
//app.UsehttpsRedirection();
app.UseStaticfiles();
app.UseRoutIng();
app.UseAuthorization();
}
我的要求 - 有没有办法在启动类之外访问 IApplicationBuilder,以便我可以使用它并映射在客户端创建的自定义集线器。
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的ASP.Net Core SignalR - 在启动类之外访问 IApaplicationBuilder 以调用 MapHub 方法全部内容,希望文章能够帮你解决ASP.Net Core SignalR - 在启动类之外访问 IApaplicationBuilder 以调用 MapHub 方法所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。