简体   繁体   中英

I Cannot go to page on wwwroot ASP.NET & React.js

I have a problem with my project.
Before I describe it, I'll write my road to publish: First I run build frontend project ( react ), and put build file to wwwroot ( .NET Core Web Api ).
When all is ready (backend and frontend in one solution) i send to server.
Now, when i go to home page and login, register everythings is ok. Problem is when i try going to page after login (when I'm not logged), or go to the confirmation email page, browser show me a not found page error.
Also when i run only build folder all page are working, and when I go to page after login (when I'm not logged), app redirects me to login page.
Under is my startup code:

   public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {


            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // 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.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseAuthentication();
            app.UseHttpsRedirection();
            app.UseMvc();
        }

       }
}

Do you have any solution for this problem?

You need to add some routes like this:

app.UseSwagger();
app.UseSwaggerUI(
            options =>
            {
                foreach (var description in apiProvider.ApiVersionDescriptions)
                {
                    options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant());
                }
            });
app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "api",
                template: "api/{controller=Home}/{action=Index}/{id?}");

            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM