标签:nbu 分享图片 sof cookie spn pac site DDM etc
这是服务端的消息
这是客户端的消息,可以看到 无论那边调用 的都同样显示了。
之前一个问题折腾了 大半天要贴出来给大家提个醒
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using SignalRChat.Hubs; namespace SignalRChat { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddCors(options => options.AddPolicy("CorsPolicy", builder => { builder.AllowAnyMethod().AllowAnyHeader() .WithOrigins("http://localhost:12754") .AllowCredentials(); })); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSignalR(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseCors("CorsPolicy"); //之前这句写到 下面去了导致一直报跨域访问的错误,顺序必须在 app.UseSignalR ... 这句设置之前才行, app.UseSignalR(route => { route.MapHub<ChatHub>("/chathub"); }); app.UseMvc(); } } }
标签:nbu 分享图片 sof cookie spn pac site DDM etc
原文地址:https://www.cnblogs.com/ProjectDD/p/9534585.html