asp.net core spa applications (angular) deployed at the same site

  Requirements: An application is now developing separate front and rear end, front-end angular, backend asp.net core provides api, after the development is completed, the two programs now need to be deployed under the same site, how they deal with?

  First, you can refer to Microsoft's official documentation   Use the Angular project template with ASP.NET Core

   .net core before and after the end of the deployment is still very friendly, the main processing steps are as follows:

   1. In the startup configuration service ConfigureServices in () declared

   

   services.AddSpaStaticFiles (Configuration => {
                 // Angular folder where the file 
                configuration.RootPath = " Client " ; 
            });

2. Call service, Configure the startup of the () method is declared

   app.UseStaticFiles();
            // spa files
            app.UseSpaStaticFiles();
     
            app.UseMvc(routes =>
            { 
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}");
                
            });
            //使用服务
            app.UseSpa(f =>
            {
                //f.Options.SourcePath = @"\client";
                if (env.IsDevelopment())
                {
            // 本地调试用 f.UseProxyToSpaDevelopmentServer(
"http://localhost:4200"); } });

Here we must note, app.usespa to put behind app.usemvc, whether the person was not adjust the front of the back end api.

3 Deployment: 

  Front and rear ends are released, in iis in the backend deployed at the same time, the establishment of a "client" folder (the first step of configuration) at the back end of the folder, the files are placed into a good front-end publishing this directory on it.

 

Guess you like

Origin www.cnblogs.com/jidanfan/p/11546490.html