且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

通过IIS进行网站部署:无法访问网站

更新时间:2023-12-02 15:44:22

@salli我通过 https:// localhost:443 / ,因为我已经添加了此绑定。但是,除了证书中的错误(证书颁发给* .my.me之类的东西)之外,我在启动应用程序时也出错。在这里,我显示该站点的日志:

@salli I accessed the site via https://localhost:443/ since I had added this binding. However, besides the error in the certificate (the certificate is issued to something like *.my.me), I have an error in the launching of the app. Here I show the log of the site:

#Software: Microsoft Internet Information Services 8.5
#Version: 1.0
#Date: 2020-01-30 14:35:38
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
2020-01-30 14:35:38 ::1 GET / - 443 - ::1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 502 5 2147500037 859
2020-01-30 14:44:14 ::1 GET / - 443 - ::1 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 502 5 2147500037 1078

下一步,我显示我的Startup.cs:

Next I show my Startup.cs:

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

        public IConfiguration Configuration { get; }

        public AppFeatures features { get; set; }

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

            services.AddIdentity<AppUser, IdentityRole>(opts =>
            {
                opts.Password.RequiredLength = 6;
                opts.Password.RequireNonAlphanumeric = false;
                opts.Password.RequireLowercase = false;
                opts.Password.RequireUppercase = false;
                opts.Password.RequireDigit = false;
            }).AddEntityFrameworkStores<idDbContext>()
                .AddDefaultTokenProviders();

            services.ConfigureApplicationCookie(opts =>
            {
                opts.LoginPath = "/Login/Login";
                opts.AccessDeniedPath = "/Login/AccessDenied";
            });

            services.AddDbContext<fmDataContext>(options =>
            {
                var connectionString = Configuration.GetConnectionString("fmDataContext");
                options.UseSqlServer(connectionString);
            });

            services.AddTransient<AppFeatures>(x => (features = new AppFeatures
            {
                DevelopmentEnvironment = Configuration.GetValue<bool>("AppFeatures:DevelopmentEnvironment"),
                SqlServerCredentials = Configuration.GetConnectionString("fmDataContext")
            }));

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddMemoryCache();

            services.AddSession();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, 
                              IHostingEnvironment env, 
                              AppFeatures features)
        {
            app.UseExceptionHandler("/Error.html");

            if (features.DevelopmentEnvironment)
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseAuthentication();

            app.Use(async (context, next) =>
            {
                if (context.Request.Path.Value.Contains("error"))
                    throw new Exception("ERRO!");

                await next();
            });

            app.UseSession();

            app.UseMvc(routes =>
            {
                routes.MapRoute("Default",
                    "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseFileServer();

            idDbContext.CreateAdminAccount(app.ApplicationServices, Configuration).Wait();

        }
    }
}

EDIT

我解决了这个问题,启用了登录我的应用程序 web.config 如下:

I solved this problem enabling logging in my app web.config as following:

<aspNetCore processPath=".\MVF2.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />

然后我能够在的日志文件中看到错误。\ \logs 目录。