aal*_*nci 20 c# asp.net iis asp.net-core
我为 IIS 提供了 Windows 中的所有功能,但如果您有建议,请与我分享。无论如何,我想部署在 IIS Lan 服务器上,但我不能。我不知道如何解决这个问题。我使用“.net.5.0”。\n我的应用程序代码如下:
\n程序.cs
\npublic class Program\n{\n public static void Main(string[] args)\n {\n var host = new WebHostBuilder()\n .UseKestrel()\n .UseContentRoot(Directory.GetCurrentDirectory())\n .UseIISIntegration().UseUrls("http://localhost:8080/")\n .UseStartup<Startup>()\n .Build();\n } \n}\nRun Code Online (Sandbox Code Playgroud)\n启动
\nnamespace EcommerceGastro.API\n{\n public class Startup\n {\n public Startup(IConfiguration configuration)\n {\n Configuration = configuration;\n }\n\n public IConfiguration Configuration { get; }\n\n // This method gets called by the runtime. Use this method to add services to the container.\n public void ConfigureServices(IServiceCollection services)\n {\n\n services.AddDbContext<GastroDB>();\n services.AddScoped<IMainCategoryService, MainCategoryService>();\n services.AddScoped<IProductService, ProductService>();\n services.AddScoped<ICategoryService, CategoryService>();\n services.AddScoped<IUploadImageService, UploadImageService>();\n services.AddAutoMapper(typeof(AutoMapperProfile));\n services.AddControllers();\n services.AddControllers().AddNewtonsoftJson(opt =>\n {\n opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;\n });\n }\n\n // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.\n public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\n {\n if (env.IsDevelopment())\n {\n app.UseDeveloperExceptionPage();\n }\n\n app.UseRouting();\n app.UseStaticFiles();\n //Initiliazer.HomePageControl().Wait();\n app.UseAuthorization();\n\n app.UseEndpoints(endpoints =>\n {\n endpoints.MapControllers();\n });\n }\n }\n}\n\nRun Code Online (Sandbox Code Playgroud)\n应用程序设置.json
\n{\n "Logging": {\n "LogLevel": {\n "Default": "Information",\n "Microsoft": "Warning",\n "Microsoft.Hosting.Lifetime": "Information"\n }\n },\n "AllowedHosts": "*",\n "ConnectionStrings": { "DefaultConnection": "server=.; database=GastroDB; user id=sa; password=123;" }\n}\n\n\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\nPayla\xc5\x9f\xc4\xb1lm\xc4\xb1yor = 不共享\n
我的错误:
\nApplication \'/LM/W3SVC/1/ROOT\' with physical root \'C:\\Users\\Tu\xc4\x9f\xc3\xa7e\\Desktop\\iisDeneme\\EcommerceGastro.API\\bin\\Release\\net5.0\\publish\\\' failed to load coreclr. Exception message:\nCLR worker thread exited prematurely\nRun Code Online (Sandbox Code Playgroud)\nApplication \'/LM/W3SVC/1/ROOT\' with physical root \'C:\\Users\\Tu\xc4\x9f\xc3\xa7e\\Desktop\\iisDeneme\\EcommerceGastro.API\\bin\\Release\\net5.0\\publish\\\' has exited from Program.Main with exit code = \'0\'. Please check the stderr logs for more information.\nRun Code Online (Sandbox Code Playgroud)\n我浏览这个 iis 网络应用程序,它已打开,但看起来像:
\nHTTP Error 500.30 - ASP.NET Core app failed to start\nCommon solutions to this issue:\nThe app failed to start\nThe app started but then stopped\nThe app started but threw an exception during startup\nTroubleshooting steps:\nCheck the system event log for error messages\nEnable logging the application process\' stdout messages\nAttach a debugger to the application process and inspect\nFor more information visit: https://go.microsoft.com/fwlink/?LinkID=2028265\nRun Code Online (Sandbox Code Playgroud)\n
Bod*_*ous 23
就我而言,问题在于它在 32 位应用程序池上运行,但该应用程序Framework-Dependent是以win-x64. 当我将其切换到win-x86我的应用程序开始工作时,我进行了调查并发现了应用程序池的问题。我创建了一个新的应用程序池,禁用了 32 位,将我的应用程序切换到该池,然后重新发布,然后它就工作了。
编辑添加:我有第二个应用程序由于不同的原因显示相同的行为。在第二种情况下,这是因为我使用 Serilog 将日志文件写入应用程序的根目录。但由于应用程序池没有该目录的写入权限,因此失败并抛出错误500.30。授予应用程序池对其目录的写入权限解决了该问题。
解决此错误的最常见和最简单的方法是重新发布代码,但打开“删除目标位置的其他文件”选项。这将确保 Visual Studio\xe2\x80\x99s Web 部署过程在复制新代码文件之前从 Web 应用程序中删除所有现有文件。这将导致发布完成后,Web 应用程序文件系统中仅存在所发布的必要文件。它还确保所有文件都被最新版本覆盖;以防这也可能以某种方式造成干扰。
\n要启用“删除目标位置的其他文件”设置,请单击 Visual Studio 中“发布配置文件”上的“编辑”。该设置位于“文件发布选项”可扩展区域下方的“设置”选项卡上。选中该框以启用该功能,然后单击“保存”。
\n| 归档时间: |
|
| 查看次数: |
63185 次 |
| 最近记录: |