0

I have a question regarding the cleanest/easiest way to fix a routing issue. To start off, I'm using the .NET 5 framework, and have the following setup in my Startup.cs:

     public void ConfigureServices(IServiceCollection services) {
         ...
         services.AddSpaStaticFiles(configuration => { configuration.RootPath = "UI"; });
         ...
     }
        
        
        
     public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
                 ...
                 app.UseRouting();
                 app.UseSpaStaticFiles();
                 app.UseAuthorization();
        
                 app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        
                 app.UseSpa(spa =>
                 {
                     if (!env.IsDevelopment()) return;
                     spa.Options.SourcePath = "UI/";
                     spa.UseVueCli();
                 });
                 ...
     }

Now, my problem seems to be an issue with the server side routing behavior, however I will let you diagnose. Basically, I am returning a Redirect method that redirects to a CLIENT SIDE route, (the route does NOT exist on the server side), and so when my client receives the response, it always receives the response as a 404 error message. However, if I click the request in the network tab in my browser debugger, it ends up redirecting to the client endpoint properly. I was wondering how I could resolve this 404 error and smoothly redirect to that client endpoint.

Thanks

Matt A
  • 13
  • 3
  • Since 404 is returned if that path is not found on the server. Now a simple solution would be if you return with a boolean from server-side and on client-side if it is true, run script to redirect to your client-side page with the client-side script. – Sayyed Dawood May 05 '21 at 16:17
  • See if [call Angular route from .Net core](https://stackoverflow.com/questions/55948520/call-an-angular-route-from-asp-net-web-api) helps. – Sayyed Dawood May 05 '21 at 16:20

0 Answers0