ASP. NET Развертывание ядра в azure с получением ошибки, включите среду разработки, установив параметр ASPNETCORE_ENVIRONMENT - PullRequest
0 голосов
/ 13 июля 2020

Итак, я пытаюсь опубликовать sh свое первое. net основное приложение на портале azure и получаю ошибку, связанную с "ASPNETCORE_ENVIRONMENT", нормально работающим при локальном запуске

enter image description here

настройки приложения. json

    {
      "ConnectionStrings": {
        "DefaultConnection": "Data Source=.;Initial Catalog=Blog;Integrated Security=True",
       "Production": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
      },
    
      "Logging": {
        "LogLevel": {
          "Default": "Information",
          "Microsoft": "Warning",
          "Microsoft.Hosting.Lifetime": "Information"
        }
      },
    
    
      "AllowedHosts": "*"

}

Файл запуска

 public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext<IdentitysAppContext>(options =>
                options.UseSqlServer(
                    Configuration.GetConnectionString("Production")));




            services.AddIdentity<AppUser, AppUserRole>(con =>
            {
           //     con.Password.RequiredLength = 4;
                con.Password.RequireDigit = false;
                con.Password.RequireNonAlphanumeric = false;
                con.Password.RequireUppercase = false;

            }).AddDefaultTokenProviders()
                  .AddEntityFrameworkStores<IdentitysAppContext>();





            services.ConfigureApplicationCookie(_cookies =>
            {

                _cookies.LoginPath = "/Account/Login";
                _cookies.Cookie.Name = "CoreCookieTempName";
            });
            services.AddControllersWithViews();
            services.AddRazorPages();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            //app.UseDeveloperExceptionPage();
            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //    app.UseDatabaseErrorPage();
            //}
            //else
            //{
                app.UseExceptionHandler("/Home/Error");
                // 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.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();



            app.UseEndpoints(endpoints =>
            {



                //endpoints.MapControllerRoute(name: "blog",
                //pattern: "blog/{*article}",
                //defaults: new { controller = "Blog", action = "Article" });

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });



        }}
...