public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>(); public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
return WebHost.CreateDefaultBuilder(args).UseStartup<Startup>();
}
 Action<object> action =
//函数参数
(object obj)
=>
//函数体
{
Console.WriteLine("");
}; public void action <T>(object obj)
{
Console.WriteLine("");
}
public void test()
{
Action<object> action = new Action<object>(action<object>);
action(new object()); //执行
}
  //我的自定义委托
public delegate Task Request_Delegate(HttpContext context);
//我的自定义函数
public Task My_Function(HttpContext context)
{
return context.Response.WriteAsync("");
}
  /*
写法1
*/
app.Run(
async (context)
=>
{
await context.Response.WriteAsync("Hello World!_001");
}
);
/*
写法 2
*/
test(app); app.Run(
(context) // 类似于匿名函数
=>
{
return context.Response.WriteAsync("Hello World!");
}
#region --定义带参数的委托
//定义一个委托
public delegate TResult My_Func001<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
public delegate string My_Func0011<in T1, in T2, out TResult>(T1 arg1, T2 arg2);
public string my_func001<T1,T2>(int a,int b)
{
MessageBox.Show("");
return "";
}
/*
My_Func001<int, int,string> my_Func001 = my_func001<int, int>;
my_Func001(1,2); My_Func0011<int, int, string> my_Func001 = my_func001<int, int>;
my_Func001(1, 2); */ public delegate void My_Func002<in T1, in T2>(T1 arg1, T2 arg2);
public void my_func002<T1,T2>(T1 a,T2 b){}
/*
My_Func002<int,int> my_Func002 = my_func002<int, int>;
my_Func002(10,11);
*/
#endregion #region --定义无参数的委托
public delegate void My_Func003<in T1, in T2>(); //无参数
public void my_func003()
{
MessageBox.Show("");
}
public void my_func003<T>()
{
var t = typeof(T);
MessageBox.Show("003<T>" + t.Name);
}
public void my_func003<T1, T2>()
{
var t = typeof(T1);
MessageBox.Show("003<T1,T2>" + t.Name);
}
/*
调用
//声明委托
My_Func003<int, int> my_Func003 = my_func003;
My_Func003<int, int> my_Func003_1 = my_func003<String>;
My_Func003<int, int> my_Func003_12 = my_func003<String, String>;
//执行委托
my_Func003();
my_Func003_1();
my_Func003_12();
*/ #endregion

//研究中e......

namespace WebApplication1.lib
{
//定义一个接口
public interface My_IApplicationBuilder
{
My_IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
}
public static class A
{
// public delegate TResult Func<in T, out TResult>(T arg); public static T test<T>(T a)
{
T temp = default(T); return temp;
}
public static My_IApplicationBuilder testc(this My_IApplicationBuilder app, string str)
{ Func<RequestDelegate, RequestDelegate> middleware = test<RequestDelegate>;
//执行这个函数
//return app.Use(middleware); //函数当参数传递过去 //委托赋值方式 2
Func<RequestDelegate, RequestDelegate> middleware1 = delegate (RequestDelegate next)
{ //返回方法001
MethodInfo[] array = new MethodInfo[] { };
MethodInfo methodInfo = array[];
return (RequestDelegate)new object(); }; //匿名方法 return app.Use(middleware1); //函数当参数传递过去
} }
}

gg了

.net core    如何获取 每次请求URL    比如  http://localhost:62830/h        http://localhost:62830/a.txt     http://localhost:62830/a.jpg   http://localhost:62830/a     http://localhost:62830/b

服务器如何获取 每次的请求连接?????

         //app.Run(My_Function);  // 放在 app.UseMvc 之后,将捕获不到控制器页面       捕获所有请求

 ////我的自定义函数
//public async Task My_Function( HttpContext context)
//{
// //RequestHandleHelper request = new RequestHandleHelper(context.Request);
// //var t = ; //请求路径 // var path = context.Request.Path.Value;
// var met = context.Request.Method; // //包含的文件扩展名
// if (path=="1")
// {
// //context.Response.Redirect(path);
// //await context.Response.WriteAsync("Hello, World!");
// }
// else if(path== "/123")
// {
// context.Response.Redirect("/Home/Error");
// }
//}

//其他委托

 //定义一个接口
public interface My_IApplicationBuilder
{
My_IApplicationBuilder Use(Func<RequestDelegate, RequestDelegate> middleware);
}
public static class A
{
// public delegate TResult Func<in T, out TResult>(T arg); public static T test<T>(T a)
{
T temp = default(T); return temp;
}
public static My_IApplicationBuilder testc(this My_IApplicationBuilder app, string str)
{ Func<RequestDelegate, RequestDelegate> middleware = test<RequestDelegate>;
//执行这个函数
//return app.Use(middleware); //函数当参数传递过去 //委托赋值方式 2
Func<RequestDelegate, RequestDelegate> middleware1 = delegate (RequestDelegate next)
{ //返回方法001
MethodInfo[] array = new MethodInfo[] { };
MethodInfo methodInfo = array[];
return (RequestDelegate)new object(); }; //匿名方法 return app.Use(middleware1); //函数当参数传递过去
} }

C# => 写法的更多相关文章

  1. obj.style.z-index的正确写法

    obj.style.z-index的正确写法 今天发现obj.style.z-index在js里面报错,后来才知道在js里应该把含"-"的字符写成驼峰式,例如obj.style.z ...

  2. java设计模式之单例模式(几种写法及比较)

    概念: Java中单例模式是一种常见的设计模式,单例模式的写法有好几种,这里主要介绍三种:懒汉式单例.饿汉式单例.登记式单例. 单例模式有以下特点: 1.单例类只能有一个实例. 2.单例类必须自己创建 ...

  3. .NET跨平台之旅:数据库连接字符串写法引发的问题

    最近在一个ASP.NET Core站点中遇到一个奇怪问题.当用dotnet run命令启动站点后,开始的一段时间请求执行速度超慢,有时要超过20秒,有时甚至超过1分钟,日志中会记录这样的错误: Sys ...

  4. 【兼容写法】HttpServerUtility.Execute 在等待异步操作完成时被阻止。关键词:MVC,分部视图,异步

    异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html MVC6之前的版本,对分部视图的异步支持不是很好 问题: 视图里面有分布视图:@{ ...

  5. 常用原生JS方法总结(兼容性写法)

    经常会用到原生JS来写前端...但是原生JS的一些方法在适应各个浏览器的时候写法有的也不怎么一样的... 今天下班有点累... 就来总结一下简单的东西吧…… 备注:一下的方法都是包裹在一个EventU ...

  6. touchstart,touchmove,touchend事件 写法

    jQuery写法: $('#id').on('touchstart',function(e) { var _touch = e.originalEvent.targetTouches[0]; var ...

  7. 前端导出Excel兼容写法

    今天整理出在Web前端导出Excel的写法,写了一个工具类,对各个浏览器进行了兼容. 首先,导出的数据来源可能有两种: 1. 页面的HTML内容(一般是table) 2. 纯数据 PS:不同的数据源, ...

  8. Express 4 handlebars 不使用layout写法

    Express 4 handlebars 不使用layout写法 Express node nodejs handlebars layout 最近刚开始学习使用nodejs. 使用express搭建了 ...

  9. javascript函数的几种写法集合

    1.常规写法 function fnName(){ console.log("常规写法"); } 2.匿名函数,函数保存到变量里 var myfn = function(){ co ...

  10. 关于java的递归写法,经典的Fibonacci数的问题

    经典的Fibonacci数的问题 主要想展示一下迭代与递归,以及尾递归的三种写法,以及他们各自的时间性能. public class Fibonacci { /*迭代*/ public static ...

随机推荐

  1. Jenkins 远程部署

    参考:https://www.cnblogs.com/bookwed/p/4583033.html 准备环境: 本地开发,安装虚拟机,在虚拟机安装Linux服务器 步骤: 1.安装插件,登录到Jenk ...

  2. python 爬虫 requests模块(response常用属性)

    response常用属性 content获取的response对象中的二进制(byte)类型的页面数据response.content 返回响应状态码response.status_code 200 ...

  3. Sublime Text 3 注册激活码

    Sublime Text 3 注册激活码 ----- BEGIN LICENSE ----- sgbteam Single User License EA7E-1153259 8891CBB9 F15 ...

  4. 2019中山纪念中学夏令营-Day19 数论初步【GCD(最大公约数),素数相关】

    关于GCD的一些定理或运用的学习: 1. 2.二进制算法求GCD 思想:使得最后的GCD没有2(提前把2提出来) 代码实现: #include <cstdio> #define int l ...

  5. Python 入门 之 初识面向对象

    Python 入门 之 初识面向对象 1.初识面向对象编程 (核心--对象) (1)观察以下代码: # 面向过程编程 s = "alexdsb" count = 0 for i i ...

  6. Tensorflow常见函数case argmax equal

    常用的函数: tf.argmax(input, axis=None, name=None, dimension=None) input:输入Tensor axis:0表示按列,1表示按行 name:名 ...

  7. 关于ionic4导入android studio的注意事项

    最近看IT营的视频的时候,发现视频讲解的打包真是轻松的不得了,但是当自己导入打包的时候,你就会发现,没有最坑,只有更坑,按照教程来打包,估计你这辈子很难还原成功的,下面就来说一下关于 gradle与g ...

  8. 03 Linux下运行Django项目

    1.安装windows和linux传输文件的工具 pip install lrzsz 提供两个命令 一个是上传一个是下载 rz 接收 直接rz sz 上传 直接sz 或者直接拖拽 2.在线下载资源的命 ...

  9. access注入

    前面有自己总结详细的mysql注入,自己access注入碰到的比较少,虽然比较简单,但是这里做一个总结 union联合查询法: 因为union前后字段数相同,所以可以先用order by 22 使查询 ...

  10. Hyperledger Fabric(1)基础架构

    前言 在区块链的家谱里,第一代区块链系统是以比特币为代表的公链,主要实现的是数字货币的功能:第二代区块链系统是以以太坊平台为代表的公链,创造性的实现了智能合约.而第三代区块链系统,则是HyperLed ...