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. CreateThread()使用实例

    1.定义的全局变量 DWORD WINAPI ClientThread(LPVOID lpParam); struct ClientInfo {   SOCKET sock;   SOCKADDR_I ...

  2. [xpath] text()和string()区别

    质区别 text()是一个node test,而string()是一个函数,data()是一个函数且可以保留数据类型.此外,还有点号(.)表示当前节点. 使用要点 XML例子: <book> ...

  3. (一)使用twisted Deferred

    一.开篇 为什么是twisted,twisted作为一个python网络编程框架,出道早,但一直不温不火,这几年和tornado比起来,更是近乎销声匿迹:但作为初学者,觉得twisted还是有很多优点 ...

  4. Redis 以及 Python操作Redis

    Redis Redis是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. Redis有以下特点: -- Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可 ...

  5. 我的python学习之旅——安装python

    windows下载安装: 1.下载安装包: 访问官方网站:https://www.python.org/downloads/ 下载自己想要的版本安装,这里下载当前最新版3.8: 选择64位的Windo ...

  6. eclipse+maven搭建springboot项目入门

    一.下载jdk,例如(jdk1.8.171) 安装(注意仅仅安装jdk就可以了,不要安装jre,设置JAVA_HOME,配置jdk环境变量) 二.下载maven(apache-maven-3.5.3- ...

  7. ASP.Net Core下Authorization的几种方式 - 简书

    原文:ASP.Net Core下Authorization的几种方式 - 简书 ASP.Net Core下Authorization的几种方式 Authorization其目标就是验证Http请求能否 ...

  8. C# 下sqlite简单使用

    1. 对数据库增, 删, 改 //数据库文件存储路径,(Environment.CurrentDirectory:为当前工作目录的完全路径) string dbPath = "Data So ...

  9. luogu P4755 Beautiful Pair

    luogu 这题有坨区间最大值,考虑最值分治.分治时每次取出最大值,然后考虑统计跨过这个位置的区间答案,然后两边递归处理.如果之枚举左端点,因为最大值确定,右端点权值要满足\(a_r\le \frac ...

  10. ubuntu - 如何以root身份使用图形界面管理文件?

    nautilus 是gnome的文件管理器,但是如果不是root账号下,权限受限,我们可以通过以下方式以root权限使用! 一,快捷键“ctrl+alt+t”,调出shell. 二,在shell中输入 ...