.NET Core 示例项目教程

.NET Core 示例项目教程

netcore-samplesThis repo contains code samples using .NET Core, which run on Windows, Mac OS and Ubuntu.项目地址:https://gitcode.com/gh_mirrors/ne/netcore-samples

1. 项目的目录结构及介绍

netcore-samples/
├── ASPNET-MVC/
├── ASPNET-WebApi/
├── ConfigurationFile/
├── EnvironmentVariables/
├── HelloWorld/
├── HelloWorld-Web/
├── MultiPlatform/
├── SQLServer/
├── Web-CustomBinding/
├── Web-CustomBinding-WebListener(Win-ONLY)/
├── Encodings/
├── EmbeddedResource/
├── Thread-Process/
└── EntityFramework/
  • ASPNET-MVC: 展示如何在.NET Core中创建ASP.NET MVC应用程序。
  • ASPNET-WebApi: 展示如何在.NET Core中创建ASP.NET Web API应用程序。
  • ConfigurationFile: 展示如何在.NET Core中使用JSON/XML/INI配置文件。
  • EnvironmentVariables: 展示不同平台间环境变量的差异。
  • HelloWorld: 展示如何在.NET Core中创建第一个Hello World应用程序。
  • HelloWorld-Web: 展示如何在.NET Core中创建一个简单的Web应用程序。
  • MultiPlatform: 展示如何在发布时针对多个平台。
  • SQLServer: 展示如何在.NET Core中连接到SQL Server。
  • Web-CustomBinding: 展示如何在Web应用程序中绑定多个URL。
  • Web-CustomBinding-WebListener(Win-ONLY): 展示如何在Web应用程序中绑定不同的/多个主机,仅在Windows下运行。
  • Encodings: 展示.NET Core中支持的编码。
  • EmbeddedResource: 展示如何在.NET Core中嵌入和读取资源。
  • Thread-Process: 展示如何在.NET Core中获取进程和线程。
  • EntityFramework: 展示如何在.NET Core中使用Entity Framework。

2. 项目的启动文件介绍

每个项目目录中都有一个Program.cs文件,这是项目的启动文件。例如,在HelloWorld项目中:

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

这个文件定义了应用程序的入口点,即Main方法。

3. 项目的配置文件介绍

ConfigurationFile项目中,展示了如何在.NET Core中使用配置文件。项目中包含以下配置文件:

  • appsettings.json
  • appsettings.xml
  • appsettings.ini

例如,appsettings.json文件内容如下:

{
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        }
    },
    "AllowedHosts": "*"
}

这个文件定义了应用程序的日志级别和允许的主机。


以上是基于https://github.com/XiaoFaye/netcore-samples.git项目的教程,涵盖了项目的目录结构、启动文件和配置文件的介绍。希望对你有所帮助!

netcore-samplesThis repo contains code samples using .NET Core, which run on Windows, Mac OS and Ubuntu.项目地址:https://gitcode.com/gh_mirrors/ne/netcore-samples

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

缪玺彬

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值