问题描述
在同一个解决方案中,我有一个ASP.NET Core项目以及其他项目,该应用程序在开发中运行良好(“ localhost:8000”),但是当我在Windows 10上将其发布到IIS(“ localhost”)时,尝试输入网址,页面为空。
我打开了事件查看器,并给我“成功启动”:
Click to view my event viewer picture
2020-10-25 15:01:17.4578 UserWeb.Program DEBUG初始化主程序 2020-10-25 15:01:17.8481 Microsoft.Hosting.Lifetime INFO应用程序已启动。按Ctrl + C关闭。 2020-10-25 15:01:17.8490 Microsoft.Hosting.Lifetime INFO托管环境:生产 2020-10-25 15:01:17.8490 Microsoft.Hosting.Lifetime INFO内容根路径:D:\ web 2020-10-25 15:01:17.9013 Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware错误执行请求时发生未处理的异常。 2020-10-25 15:01:17.9013 Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware错误尝试执行错误处理程序时引发了异常。 2020-10-25 15:01:17.9013 Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer错误连接ID“ 18230571301796315146”,请求ID“ 8000000b-0002-fd00-b63f-84710c7967bb”:应用程序引发了未处理的异常
有时我会在日志中看到此错误:
2020-10-25 16:11:05.3851 UserWeb.Program DEBUG初始化主程序 2020-10-25 16:11:05.7869 Microsoft.Hosting.Lifetime INFO应用程序已启动。按Ctrl + C关闭。 2020-10-25 16:11:05.7869 Microsoft.Hosting.Lifetime INFO托管环境:生产 2020-10-25 16:11:05.7869 Microsoft.Hosting.Lifetime INFO内容根路径:D:\ web 2020-10-25 16:11:05.8245 Microsoft.AspNetCore.Session.SessionMiddleware警告取消保护会话cookie时出错。 2020-10-25 16:11:05.8419 Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware错误执行请求时发生未处理的异常。 2020-10-25 16:11:05.8419 Microsoft.AspNetCore.Session.SessionMiddleware WARN取消保护会话Cookie时出错。 2020-10-25 16:11:05.8419 Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware ERROR试图执行错误处理程序时引发了异常。 2020-10-25 16:11:05.8419 Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer错误连接ID“ 18230571301796315163”,请求ID“ 8000001c-0002-fd00-b63f-84710c7967bb”:应用程序引发了未处理的异常
所以我认为::p
Microsoft.AspNetCore.Session.SessionMiddleware警告取消保护会话cookie的错误
这是我的Startup.cs:
using DataManager.Clients;
using DataManager.DataManagers;
using DataManager.Entities;
using DataManager.Interfaces;
using DataManager.Managers;
using DataManager.Managers.SwedishBankId;
using DataManager.sqlLiteDatabase;
using DataManager.sqlLiteDatabase.Interfaces;
using DataManager.sqlLiteDatabase.Schema;
using maxmind.GeoIP2;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using MStart.Constants;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using UserWeb.Controllers;
using UserWeb.Services;
using WebDataManager;
namespace UserWeb
{
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.AddControllersWithViews(options =>
{
options.Filters.Add(typeof(onLoadActionFilter));
});
services.AddHttpClient();
services.AdddistributedMemoryCache();
services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(31);
options.Cookie.IsEssential = true;
});
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(config =>
{
config.Cookie.Name = "M_User";
config.LoginPath = "/Home/Login";
//config.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
config.ExpireTimeSpan = new TimeSpan(0,30,0);
});
services.AddLocalization();
services.Configure<RequestLocalizationoptions>(
options =>
{
var supportedCultures = new List<CultureInfo>
{
new CultureInfo("en"),new CultureInfo("ar"),new CultureInfo("ru"),new CultureInfo("fr"),new CultureInfo("es"),};
options.DefaultRequestCulture = new RequestCulture(culture: "en",uiCulture: "en");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
options.RequestCultureProviders = new[] { new RouteDataRequestCultureProvider { IndexOfCulture = 1,IndexofUICulture = 1 } };
});
// Configure to read configuration options from maxmind section
services.Configure<WebServiceClientOptions>(Configuration.GetSection("maxmind"));
// Configure dependency injection for WebServiceClient
services.AddHttpClient<WebServiceClient>();
services.AddMvc().AddViewLocalization();
services.Configure<RouteOptions>(options =>
{
options.ConstraintMap.Add("culture",typeof(LanguageRouteConstraint));
});
services.AddHttpContextAccessor();
////////////////////////////////////
MStartConstants.IsWebPlatform = true;
//ResultManager.Current.LoadWebResources();
services.AddControllersWithViews().AddJsonoptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
services.AddScoped<IWebUserPreferences,WebUserPreferences>();
services.AddScoped<ICacheContext,CacheContext>();
services.AddScoped<IEventdispatcher,Eventdispatcher>();
services.AddScoped<IMemoryStorage<CommonTable>,MemoryStorage>();
services.AddScoped<IDataManager,UserDataManager>();
services.AddScoped<IContext<UserContext>,UserContext>();
services.AddScoped<INetworkService,NetworkService>();
services.AddScoped<IProgramClient,ProgramClient>();
services.AddScoped<IUserClient,UserClient>();
services.AddScoped<IAccountClient,AccountClient>();
services.AddScoped<IBINClient,BINClient>();
services.AddScoped<ITransactionClient,TransactionClient>();
services.AddScoped<Isqlite,sqliteService>();
services.AddScoped<IsqliteStorage,sqliteStorage>();
services.AddScoped<IUserManager,UserManager>();
services.AddScoped<ILocalStorage<CommonTable>,WebDataManager.LocalStorage>();
services.AddScoped<IGroupClient,GroupClient>();
services.AddScoped<ICatalogClient,CatalogClient>();
services.AddScoped<IOrderClient,OrderClient>();
services.AddScoped<IMessageClient,MessageClient>();
services.AddScoped<ISwedishBankIdManager,SwedishBankIdManager>();
services.AddScoped<ISettings,WebSettings>();
services.AddScoped<IWebDomainService,WebDomainService>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app,IWebHostEnvironment env,IServiceProvider serviceProvider)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseRouting();
var localizationoptions = app.applicationservices.GetService<IOptions<RequestLocalizationoptions>>().Value;
app.UseRequestLocalization(localizationoptions);
app.UseAuthentication();
app.UseAuthorization();
app.UseSession();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "Culture",pattern: "{culture}/{controller=Home}/{action=Login}/{id?}");
endpoints.MapControllerRoute(
name: "default",pattern: "{controller=Home}/{action=Login}/{id?}");
});
var files = Directory.GetFiles("..\\DataManager\\ProgramConfig","*",SearchOption.AllDirectories);
SiteConfiguration siteConfiguration = new SiteConfiguration();
List<WebConfiguration> webConfigurationsList = new List<WebConfiguration>();
WebConfiguration webConfiguration = null;
foreach (var item in files)
{
if (item.ToLower().Contains("programconfig.json"))
webConfiguration = new WebConfiguration();
var jsonString = System.IO.File.ReadAllText(item);
if (item.ToLower().Contains("programconfig.json"))
{
ProgramConfiguration programConfig = JsonConvert.DeserializeObject<ProgramConfiguration>(jsonString);
webConfiguration.programConfigurations = programConfig;
}
else
{
Theme theme = JsonConvert.DeserializeObject<Theme>(jsonString);
webConfiguration.programThemes = theme;
}
if (item.ToLower().Contains("theme.json"))
webConfigurationsList.Add(webConfiguration);
}
siteConfiguration.webConfigurations = webConfigurationsList;
CacheSettings.ProgramConfigurationTTL = Convert.ToInt32(Configuration.GetSection("SystemCacheTTL").GetSection("ProgramConfigurationTTL").Value);
var _cacheContext = serviceProvider.GetService<ICacheContext>();
_cacheContext.Insert("SiteConfiguration",siteConfiguration,CacheSettings.ProgramConfigurationTTL);
}
}
}
我如何解决它或如何在启动应用程序时对其进行调试?请指教
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)