.NET Core 6.0 Windows部署

var options = new WebApplicationOptions { Args = args, //這是因爲從Windows中調用GetCurrentDirectory會返回:C:\WINDOWS\system32 //需要注意使用了WindowsService部署,就不能使用Console類,否則會報錯 ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default }; var builder = WebApplication.CreateBuilder(options); if (WindowsServiceHelpers.IsWindowsService()) { builder.Host.UseWindowsService(); } // Add services to the container. builder.Services.AddControllers(options => { options.SuppressImplicitRequiredAttributeForNonNullableReferenceTypes = true; //兼容可爲空類型的模型校驗問題 }).AddNewtonsoftJson(options => { options.UseMemberCasing(); }); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章