天下之事,必先处之难,而后易之。
君临
知我者谓我心忧,不知我者谓我何求

原文地址:https://blog.csdn.net/iml6yu/article/details/74530679

目录结构如下图

 
目录:
Properties:属性,记录了项目属性的配置文件。
launchSettings.json:项目属性配置文件,可以直接编辑,配置内容的语法采用标准的JSON格式。
{

    //以IIS Express启动
    "iisSettings": {

    //是否启用windows身份验证
    "windowsAuthentication": false,

    //是否启用匿名身份验证
    "anonymousAuthentication": true,
    "iisExpress": {

    //IIS Express端口
    "applicationUrl": "http://localhost:35617/",
    "sslPort": 0
    }
    },

    //运行配置项
    "profiles": {
    "IIS Express": {
    "commandName": "IISExpress",
    "launchBrowser": true,
    "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
    }
    },
    "WebApplication1": {
    "commandName": "Project",
    "launchBrowser": true,
    "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
    },

    //这里配置采用application方式启动时候的端口
    "applicationUrl": "http://localhost:35618"
    }
    }
    }

 

  wwwroot:  

这里放着网站的静态资源(css,image,js等),可以在StartUp.cs中通过代码允许访问wwwroot,否则wwwroot目录内的静态资源文件将无法被加载(wwwroot目录有点类型RoR中的Public目录)

 

依赖项:不赘述,就是引用项

 

Controller和Views在这里不赘述,不了解MVC的可以在网上查一下

 

文件:

appsettings.json

同样是顾名思义——应用配置,类似于.NET Framework上的Web.Config文件,开发者可以将系统参数通过键值对的方式写在appsettings文件中(如程序的连接字符串),

而Startup类中也在构造器中通过如下代码使得程序能够识别该文件

    public Startup(IHostingEnvironment env)
    {
    var builder = new ConfigurationBuilder()
    .SetBasePath(env.ContentRootPath)
    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
    .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
    .AddEnvironmentVariables();
    Configuration = builder.Build();
    }

 

bower.json

看这里吧(https://segmentfault.com/a/1190000000349555),个人认为这个配置文件很鸡肋,类似angularjs这样的都无法提示

bundleconfig.json

压缩配置文件,看下面关于site.css的配置说明,定义了输入文件和输出文件,当网站发布之后,在发布目录中存在如下两个文件,一个是压缩文件,一个是源文件

发布目标目录/wwwroot/css/

site.css 和 site.min.css

 

    // Configure bundling and minification for the project.
    // More info at https://go.microsoft.com/fwlink/?LinkId=808241
    [
    {
    "outputFileName": "wwwroot/css/site.min.css",
    // An array of relative input file paths. Globbing patterns supported
    "inputFiles": [
    "wwwroot/css/site.css"
    ]
    },
    {
    "outputFileName": "wwwroot/js/site.min.js",
    "inputFiles": [
    "wwwroot/js/site.js"
    ],
    // Optionally specify minification options
    "minify": {
    "enabled": true,
    "renameLocals": true
    },
    // Optionally generate .map file
    "sourceMap": false
    }
    ]

 

 

下面说两个C#的文件吧

Program.cs,在.net项目中,这个文件再熟悉不过了,程序的main函数写在这个类中,也就是程序的入口。

 

Startup.cs,个人理解相当于asp.net项目中的global.aspx文件,是系统的启动全局配置文件。

下面是两个比较常用的方法

 

  // This method gets called by the runtime. Use this method to add services to the container.
    //加载服务信息,例如MVC服务
    public void ConfigureServices(IServiceCollection services)
    {
    // Add framework services.
    services.AddMvc();
    }
     
    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

    //运行时被调用,配置路由等信息。
    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
     
    if (env.IsDevelopment())
    {
    app.UseDeveloperExceptionPage();
    app.UseBrowserLink();
    }
    else
    {
    app.UseExceptionHandler("/Home/Error");
    }
     
    app.UseStaticFiles();
     
    app.UseMvc(routes =>
    {
    routes.MapRoute(
    name: "default",
    template: "{controller=Home}/{action=Index}/{id?}");
    });
    }
    }

 .NetCore 开发环境的安装与配置不再此赘述,请参考官方文档:https://www.microsoft.com/net/core#windowsvs2017

更多参考:拥抱.NET Core,如何开发跨平台的应用并部署至Ubuntu运行

posted on 2018-08-24 16:45  boonya  阅读(213)  评论(0编辑  收藏  举报

我有佳人隔窗而居,今有伊人明月之畔。
轻歌柔情冰壶之浣,涓涓清流梦入云端。
美人如娇温雅悠婉,目遇赏阅适而自欣。
百草层叠疏而有致,此情此思怀彼佳人。
念所思之唯心叩之,踽踽彳亍寤寐思之。
行云如风逝而复归,佳人一去莫知可回?
深闺冷瘦独自徘徊,处处明灯影还如只。
推窗见月疑是归人,阑珊灯火托手思忖。
庐居闲客而好品茗,斟茶徐徐漫漫生烟。

我有佳人在水之畔,瓮载渔舟浣纱归还。
明月相照月色还低,浅近芦苇深深如钿。
庐山秋月如美人衣,画堂春阁香气靡靡。
秋意幽笃残粉摇曳,轻轻如诉画中蝴蝶。
泾水潺潺取尔浇园,暮色黄昏如沐佳人。
青丝撩弄长裙翩翩,彩蝶飞舞执子手腕。
香带丝缕缓缓在肩,柔美体肤寸寸爱怜。
如水之殇美玉成欢,我有佳人清新如兰。
伊人在水我在一边,远远相望不可亵玩。