星空网 > 软件开发 > ASP.net

DotNetCore跨平台~Startup类的介绍

新宠儿

DotNetCore是.net5.0版本,之所以不叫.net5.0为的就是不让我们把它与前面的.net混为一淡,它将是真正意义的跨平台开发语言,在网上也有相关介绍,中国的一些大牛也发了相关文章,像张善友大牛也发了几个文章,来介绍.NetCore,这段时间,大叔将会一步一步说说这个跨平台的新宠儿!

重新起名了

  • ASP.NET 5 –> ASP.NET Core 1.0
  • .NET Core 5 –> .NET Core 1.0
  • Entity Framework 7 –> Entity Framework Core 1.0

起航

下载.net core 1.0.0 rc2版

DotNetCore跨平台~Startup类的介绍

Configure方法主要作用是对运行环境进行个性化配置,如调试环境(Development),生产环境(Production),跌代环境(Staging)等

 public Startup(IHostingEnvironment env)    {      var builder = new ConfigurationBuilder()        .SetBasePath(env.ContentRootPath)        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)        .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);      //判断运行环境      if (env.IsDevelopment())      {        // For more details on using the user secret store see http://go.microsoft.com/fwlink/?LinkID=532709        builder.AddUserSecrets();        // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.        builder.AddApplicationInsightsSettings(developerMode: true,endpointAddress:"localhost:5000");      }      builder.AddEnvironmentVariables();      Configuration = builder.Build();     }

需要希望修改监听的端口,需要修改program.cs程序,具体如下

     public static void Main(string[] args)    {      var host = new WebHostBuilder()          .UseKestrel()          .UseContentRoot(Directory.GetCurrentDirectory())          .UseIISIntegration()          .UseStartup<Startup>()          .UseUrls("http://192.168.2.22:5000")          .Build();      host.Run();      host.Run();    }

这样我们的第一个应用程序就可以了,它可以部署到linux,maxos等操作系统上,只需要安装dotnet-cli即可。

DotNetCore跨平台~Startup类的介绍

终于OK了,咱们的第一个跨平台的.net程序完成了!

谢谢您的阅读!




原标题:DotNetCore跨平台~Startup类的介绍

关键词:dotnet

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

法属圭亚那港口:https://www.vstour.cn/t/法属圭亚那港口.html
法属圭亚那观光景点:https://www.vstour.cn/t/法属圭亚那观光景点.html
法属圭亚那和圭亚那:https://www.vstour.cn/t/法属圭亚那和圭亚那.html
法属圭亚那蓝牙:https://www.vstour.cn/t/法属圭亚那蓝牙.html
法属圭亚那两日游路线:https://www.vstour.cn/t/法属圭亚那两日游路线.html
法属圭亚那旅行:https://www.vstour.cn/t/法属圭亚那旅行.html
珠海长隆横琴剧院具体地址:https://www.vstour.cn/a/334167.html
珠海长隆横琴剧院演出时间:https://www.vstour.cn/a/334168.html
相关文章
我的浏览记录
最新相关资讯
跨境电商服务平台 | 深圳旅行社 | 东南亚物流