venux / blog Goto Github PK
View Code? Open in Web Editor NEW博客
博客
ASP.NET Core应用只是个简单的创建Web Server的控制台应用程序。
using System;
using Microsoft.AspNetCore.Hosting;
namespace aspnetcoreapp
{
public class Program
{
var host=new WebHostBuilder()
.UserKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
说明:
WebHostBuilder对象的UseStartup方法用来指明应用程序的Startup类。
IApplicationBuilder
中注入中间件(middleware)来配置请求管道。public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app)
{
}
}
Startup
类,默认情况下命名为Startup,可通过UseStartup方法指定自定义的Startup
类名;Startup
类,运行时(runtime)会自动选择合适的Startup
;startupAssembly
,则宿主会加载对应程序集,并在其中搜索Startup
或Startup[Environment]
的对象的类型,参见StartupLoader类的FindStartupType;
//查找程序集的Startup类
public static Type FindStartupType(string startupAssemblyName, string environmentName)
{
if (string.IsNullOrEmpty(startupAssemblyName))
{
throw new ArgumentException(
string.Format("A startup method, startup type or startup assembly is required. If specifying an assembly, '{0}' cannot be null or empty.",
nameof(startupAssemblyName)),
nameof(startupAssemblyName));
}
var assembly = Assembly.Load(new AssemblyName(startupAssemblyName));
if (assembly == null)
{
throw new InvalidOperationException(String.Format("The assembly '{0}' failed to load.", startupAssemblyName));
}
var startupNameWithEnv = "Startup" + environmentName;
var startupNameWithoutEnv = "Startup";
// Check the most likely places first
var type =
assembly.GetType(startupNameWithEnv) ??
assembly.GetType(startupAssemblyName + "." + startupNameWithEnv) ??
assembly.GetType(startupNameWithoutEnv) ??
assembly.GetType(startupAssemblyName + "." + startupNameWithoutEnv);
if (type == null)
{
// Full scan
var definedTypes = assembly.DefinedTypes.ToList();
var startupType1 = definedTypes.Where(info => info.Name.Equals(startupNameWithEnv, StringComparison.Ordinal));
var startupType2 = definedTypes.Where(info => info.Name.Equals(startupNameWithoutEnv, StringComparison.Ordinal));
var typeInfo = startupType1.Concat(startupType2).FirstOrDefault();
if (typeInfo != null)
{
type = typeInfo.AsType();
}
}
if (type == null)
{
throw new InvalidOperationException(String.Format("A type named '{0}' or '{1}' could not be found in assembly '{2}'.",
startupNameWithEnv,
startupNameWithoutEnv,
startupAssemblyName));
}
return type;
}
ASPNETCORE_ENVIRONMENT 环境变量
Development 开发环境
Staging 预发布、部署上线前的最终测试环境、生产环境的物理镜像
Production 生产环境(安全性、高性能、稳健性)
bundled
,minified
或 CDN
diagnostic ErrorPages
friendly error pages
production logging
和 monitoring
注:
Windows 不区分大小写,Linux 默认区分大小写。
设置:右键项目属性-调试-环境变量,另在 ~\Properties\launchSettings.json
可看到具体配置。
Secret Manager
存放加密信息。本机设置
set ASPNETCORE_ENVIRONMENT=Development
UML Distilled-Martin Fowler
*
:0个或多个;Markdown是一种在web显示带样式风格文本的方式。你能通过它控制文本的字体样式、插入图片、插入列表等。通常,Markdown使用一些特殊的非字母符号来作为语法规则,如#
等。
你能在Github上大部分地方使用Markdown。
Hello,World!-Coder
见上文
I think you should use an
<addr>
element here instead.
function Test(args){
if(args){
console.log(args);
}
}
public class Test
{
static void Main()
{
Console.WriteLine("Hello,World!");
}
}
表头一 | 表头2 |
---|---|
11 | 12 |
21 | 22 |
5e0b770018f87bd7fafecb7b3920cda8a30d4740
删除
👍
查看当前Fork项目已配置的远程仓库(List the current configured remote repository for your fork)
url
指定将要同步Fork项目的一个远程上游仓库(Specify a new remote upstream repository that will be synced with the fork.)
再次查看
拉取上游仓库的所有分支和更改记录,mater分支提交记录会在本地分支中保存。(Fetch the branches and their respective commits from the upstream repository. Commits to master will be stored in a local branch, upstream/master.)
迁出本地master分支(Check out your fork's local master branch.)
将上游仓库的master分支更改记录合并到本地master分支中,即同步且不会丢失本地更改记录。(Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.)
注意:INCR命令是原子操作(即不会被线程调度机制打断的操作)
;HINCRBY
(原子操作)累加object-type:id
,通常使用:
、-
、.
分割。例如user:1000
、comment:1234:reply.to
、comment:1234:reply-to
;Memcached
一样,string作为唯一的数据类型;i++
);AssemblyInfo中
更改[assembly: AssemblyVersion("1.0.*")]
注释[assembly: AssemblyFileVersion("1.0.0")]
nopCommerce is the best open-source e-commerce shopping cart. nopCommerce is available for free. Today it's the best and most popular ASP.NET ecommerce software. It has been downloaded more than 1.8 million times!
Castle Windsor is a best of breed, mature Inversion of Control container available for .NET.
决定向用户提供应用服务时通信的活动。
TCP/IP协议簇内预存了各类通用的应用服务,如FTP文件传输协议,DNS域名系统服务。HTTP协议也在该层。
对上层应用层提供处于网络连接中两台计算机间的数据传输。
在传输层有两个性质不同的协议:TCP(Transmission Control Protocol,传输控制协议)和UDP(User Data Protocol,用户数据报协议)。
处理在网络上流动的数据包(网络传输的最小数据单位),该层规定了通过怎样的路径到达对方计算机,并把数据包传送给对方。
用来处理连接网络的硬件部分,包括控制操作系统,硬件设备驱动,网络适配器(网卡)及光纤等物理可见部分。
IP(Internet Protocol)网际协议位于网络层。TCP/IP协议簇中的IP指的就是网际协议。
作用是把各种数据包发送给对方,而要确保发送正确需满足各类条件,其中两个重要的就是IP地址和MAC(Media Access Control Address)地址。
IP地址指明节点被分配的地址,MAC地址指网卡的固定地址,可配对。IP地址可变换而MAC地址基本不变。
ARP(Address Resolution Protocol)协议是一种用以解析地址的协议,根据通信方的IP地址反查出对应的MAC地址。
TCP协议位于传输层,提供可靠的字节流服务。采用三次握手(three-way handshaking)策略:发送端先发送带SYN(synchronize)标志的数据包给对方,接收端接受到后回传一个带SYN/ACK(acknowledgement)标志的数据包确认,最后,发送端回传ACK标志的数据包,表示握手结束。
DNS(Domain Name System)服务用于域名到IP地址之间解析,位于应用层。
由某个协议方案表示的资源的定位标识符。
规定统一的格式可方便处理多种不同类型的资源,而不用根据上下文环境来识别资源指定的访问方式。
资源的定义是可标识的任何东西。
表示可标识的对象,即标识符。
资源的地点,是URI的子集。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.