当前位置: 首页 > news >正文

广州网站建设技术方案网站布局优化

广州网站建设技术方案,网站布局优化,塑胶加工东莞网站建设技术支持,wordpress 显示错误500效果图#xff1a; 1.新建.net core web api项目 选择src文件夹》添加》新建项目 输入框搜索#xff1a;web api 》选择ASP.NET Core Web API 输入项目名称、选择位置为项目的 src文件夹下 我的项目是net 7.0版本#xff0c;实际选择请看自己的项目规划 2.处理Progr…效果图 1.新建.net core web api项目 选择src文件夹》添加》新建项目 输入框搜索web api 》选择ASP.NET Core Web API 输入项目名称、选择位置为项目的 src文件夹下 我的项目是net 7.0版本实际选择请看自己的项目规划 2.处理Program入口文件引入日志和新建Startup.cs 需要安装NuGet程序依赖包Newtonsoft.Json、Serilog.AspNetCore、Serilog.Sinks.Async、Serilog.Sinks.File Program文件代码如下 /// summary/// /// /summarypublic class Program{/// summary/// /// /summary/// param nameargs/parampublic static int Main(string[] args){Log.Logger new LoggerConfiguration() #if DEBUG.MinimumLevel.Debug() #else.MinimumLevel.Information() #endif.MinimumLevel.Override(Microsoft, LogEventLevel.Information).MinimumLevel.Override(Microsoft.EntityFrameworkCore, LogEventLevel.Warning).Enrich.FromLogContext().WriteTo.Async(c c.File(Logs/logs.txt, rollingInterval: RollingInterval.Hour)) #if DEBUG.WriteTo.Async(c c.Console()) #endif.CreateLogger();// Wrap creating and running the host in a try-catch blocktry{Log.Information(Starting host);CreateHostBuilder(args).Build().Run();return 0;}catch (Exception ex){Log.Fatal(ex, Host terminated unexpectedly);return 1;}finally{Log.CloseAndFlush();}}/// summary/// 载入Startup配置、以及新增日志/// /summary/// param nameargs/param/// returns/returnspublic static IHostBuilder CreateHostBuilder(string[] args) Host.CreateDefaultBuilder(args).UseSerilog().ConfigureWebHostDefaults(webBuilder {var configuration new ConfigurationBuilder().AddJsonFile(appsettings.json).Build();var url configuration[Urls];webBuilder.UseUrls(url);webBuilder #if !DEBUG.UseEnvironment(ASPNETCORE_HOSTINGSTARTUPASSEMBLIES) #endif.UseStartupStartup();});}Startup文件代码如下 /// summary /// /// /summary public class Startup {/// summary/// /// /summary/// param nameconfiguration/parampublic Startup(IConfiguration configuration){Configuration configuration;}/// summary/// /// /summarypublic IConfiguration Configuration { get; }/// summary/// This method gets called by the runtime. Use this method to add services to the container./// /summary/// param nameservices/parampublic void ConfigureServices(IServiceCollection services){services.AddControllers();services.AddSwaggerGen(c {c.SwaggerDoc(v1, new OpenApiInfo { Title 这里替换成你新建webApi项目的名称, Version v1 });var basePath PlatformServices.Default.Application.ApplicationBasePath;var XmlPath Path.Combine(basePath, 这里替换成你新建webApi项目的名称.xml);//此处生成xml文档c.IncludeXmlComments(XmlPath);});//处理跨域问题services.AddCors(option {option.AddPolicy(any, policy {policy.SetIsOriginAllowed(_ true) //允许所有客户端地址请求.AllowAnyHeader().AllowAnyMethod().AllowCredentials();});});services.AddMemoryCache();services.AddHttpContextAccessor();}/// summary/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline./// /summary/// param nameapp/param/// param nameenv/parampublic void Configure(IApplicationBuilder app, IWebHostEnvironment env){if (env.IsDevelopment()){app.UseDeveloperExceptionPage();}app.UseSerilogRequestLogging();app.UseRouting();app.UseCors(any);//处理跨域问题app.UseSwagger();app.UseSwaggerUI(c c.SwaggerEndpoint(/swagger/v1/swagger.json, 这里替换成你新建webApi项目的名称 v1));app.UseAuthorization();app.UseEndpoints(endpoints {endpoints.MapControllers().RequireCors(any);});} }appsettings.json代码如下 {Logging: {IncludeScopes: false,Debug: {LogLevel: {Default: Warning}},Console: {LogLevel: {Default: Warning}},LogLevel: {Default: Information,Microsoft: Warning,Microsoft.Hosting.Lifetime: Information}},Urls: http://*:44375;,AllowedHosts: *}3.处理launchSettings.json文件使本地启动项目时是以iis运行 {iisSettings: {windowsAuthentication: false,anonymousAuthentication: true,iisExpress: {applicationUrl: http://localhost:44375,sslPort: 0}},profiles: {IIS Express: {commandName: IISExpress,launchBrowser: true,launchUrl: swagger,environmentVariables: {ASPNETCORE_ENVIRONMENT: Development,ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: SkyAPM.Agent.AspNetCore}},这里替换成你新建webApi项目的名称: {commandName: Project,launchBrowser: true,dotnetRunMessages: true,launchUrl: swagger,applicationUrl: http://localhost:44375,environmentVariables: {ASPNETCORE_ENVIRONMENT: Development,ASPNETCORE_HOSTINGSTARTUPASSEMBLIES: SkyAPM.Agent.AspNetCore}}} } 处理在文件里生成xml文档 4.在Controllers控制器写接口 在项目的Controllers文件夹下新建一个xxxxController.cs /// summary/// 名称/// /summary[ApiController][Route(outApi/[controller]/[action])]public class xxxxController : ControllerBase{private readonly IHttpContextAccessor _httpContextAccessor;/// summary/// /// /summarypublic questionController(IHttpContextAccessor httpContextAccessor){_httpContextAccessor httpContextAccessor;}/// summary/// 获取请求客户端的ip地址/// /summary/// returns/returns[HttpGet]public async Taskstring testIP(){Log.Information(IP: Request.HttpContext.Connection.RemoteIpAddress.ToString() InputQuestion入参 );string ipAddress _httpContextAccessor.HttpContext.Connection.RemoteIpAddress?.ToString();return ipAddress;}}5.设置项目启动项并运行 选择解决方案右键选择 配置启动项目弹窗里选择 多个启动项目》把新建的web api的操作下拉框里改成启动点击应用按钮点击确定按钮 然后按ctrlF5运行 电脑桌面右下角有iis的图标 6.打包发布 选择新建的web api项目》点击 发布 配置选择文件夹如下 文件夹位置 路径默认不管 更改配置如下 然后点击发布按钮 7.部署到centos服务器请参考我的另外一篇文章 【liunx配置服务自启动】liunx系统设置net Core程序开机自启动服务 centos系统
http://www.pierceye.com/news/367666/

相关文章:

  • 做外贸网站怎么做做网站3个月
  • 县局网站建设招标网站建设人文类
  • 网站开发亿玛酷给力5上海logo在线制作
  • 网站重新备案搞个网站需要多少钱
  • 海南微信网站制作平台网络计划的优化
  • 域名的正确书写格式自动seo优化
  • 怎样在网站做友情链接网页什么设计
  • 做seo网站营销推广南宁建设职业技术学院招聘信息网站
  • 网站建设全网推广小程序手机网站怎么优化
  • wordpress 网站logowin系统没有wordpress
  • 玉山电商网站建设东莞市建设规划局网站
  • 网站建设运营公司企业特色c2c的代表性的电商平台
  • 上海网站建设,分类广告软件公司简介
  • 网站虚拟主机被国家禁止访问的网站怎么打开
  • wordpress手机加载不出来优化官网咨询
  • 平台网站建设预算表如何来做网站
  • 温州网站制作企业东莞网络推广公司电话
  • 网站建设的条件重庆那些网站
  • 伊犁网站制作大连甘井子区房价
  • 循环视频做网站背景win2012r2 建设网站
  • 建设网站制作汉狮团队义乌北苑编程网站开发公司
  • 网站开发公司会计处理滨州市住房和城乡建设局网站
  • 企业网站站内优化长尾关键词挖掘站长工具
  • 山东平台网站建设企业怎么做自己的品牌网站
  • 长沙seo网站排名杭州网站建设q479185700棒
  • 泰州网站建设搭建工程造价网
  • 网站流程优化c2c模式举例子
  • 帝国网站调用图片集网店平台有哪些
  • 做flash音乐网站的开题报告删除wordpress左上角
  • php网站开发学什么衡水大型网站建设