angularsingle-page-applicationasp.net-core-5.0fallbackquerystringparameter

Spa with Net5.0 avoid in fall back the loss of QueryString


for my english since i m not native. First i m using Angular front/Net 5.0 back. My problem is, every time that i go to my Spa aplication (From another aplication that handles login) i loose the query string and redirect to /, how can i configure the aplication to not loose the query string? this is my configure service.

  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 = "/";
            
        });
    }

and this is my configure

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");
            }
        });
       
    }

Also the objetive of the aplication is handle a JwT as a method of authetication without a session (no cookie there). Since i m learning dont know the best way to put this toguether, would like to hear some recomendations. Thanks for your help.


Solution

  • Just if some one has the same problem, it has nothing to do with Spa redirection/fallback of .Net Core, The problem came of how angular (Client side) do routes, so the token was receive by the front, but erased somehow with a redirect (client side).