angular - Spa with Net5.0避免了QueryString的丢失
问题描述
因为我不是本地人,所以我的英语。首先我使用 Angular front/Net 5.0 back。我的问题是,每次我去我的 Spa 应用程序(从另一个处理登录的应用程序)时,我都会丢失查询字符串并重定向到 /,我如何配置应用程序以不丢失查询字符串?这是我的配置服务。
public void ConfigureServices(IServiceCollection services)
{
string mySqlConnectionStr = Configuration.GetConnectionString("DefaultConnection");
services.AddControllers();
services.AddDbContextPool<recursoContext>(options => options.UseMySQL(mySqlConnectionStr));
services.AddLogging();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebContainerUI", Version = "v1" });
});
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "/";
});
}
这是我的配置
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebContainerUI v1"));
}
app.UseHttpsRedirection();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseRouting();
app.UseMiddleware<Jwt.JwtMiddleware>();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapFallbackToFile("/index.html");
});
app.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA from ASP.NET Core,
if (env.IsDevelopment())
{
// spa.UseAngularCliServer(npmScript: "start");
}
});
}
此外,应用程序的目标是将 JwT 处理为一种没有会话的身份验证方法(那里没有 cookie)。由于我正在学习不知道将其结合起来的最佳方法,因此想听听一些建议。谢谢你的帮助。
解决方案
只是如果有人有同样的问题,它与.Net Core的Spa重定向/回退无关,问题出在角度(客户端)如何做路由,所以令牌被前面接收,但不知何故被删除了重定向(客户端)。
推荐阅读
- pandas - 如何“快速”在熊猫中针对某一列添加行数据值?
- vim - Vim - 命令行 - 上一个和下一个命令键映射
- javascript - javascript Boolean() 函数无法正常工作
- r - 将字符缓冲区移植到 Rcpp
- debugging - 如何在 GDB 中判断地址属于哪个模块
- algorithm - 满足图中的三元组
- javascript - 用正则表达式替换数据,我的表达式正则不起作用 - JavaScript
- javascript - Gson.fromJson 卡在了线上
- powershell - Powershell Cmdlet 别名文档
- postgresql - 无法从 Docker 容器内部连接到 Postgres