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. 使用PowerShell 自动创建DFS复制组

    运行环境:Windows Server 2012 R2 DFS 复制概述  DFS复制组 PowerShell脚本命令 需要注意的是DFS依赖域,若此服务器未存在于域控上,或未存在域内,则此脚本会报错 ...

  2. String的非空判断:str!=""的为空判断出错问题

    if(str!=null && str!= ""){}这是错误的判断 String str1 = ""; String str2 = new S ...

  3. Laravel模板事项

    1.模板中己显示的时间,可以在此基础上增加时间 请于{{ $order->created_at->addSeconds(config('app.order_ttl'))->forma ...

  4. [LGP4859,...] 一类奇怪的容斥套DP

    漫山遍野都是fake的光影. 题目 [LGP4859] 已经没有什么好害怕的了 给定两个长度为n的数组a和b,将a中元素与b中元素配对,求满足ai>bj的配对(i,j)个数减去满足ai<b ...

  5. 通过Playbook部署LAMP

    Ansible的PlayBook文件格式为YAML语言,所以希望你在编写PlayBook前对YAML语法有一定的了解,否则在运行PlayBook的时候经常碰到语法错误提示,这里我们通过介绍批量部署LA ...

  6. 将Abp的UnitTest中的InMemory改为SQLite in memory

    添加nuget包 Microsoft.EntityFrameworkCore.Sqlite 添加ServiceCollectionRegistrarSqlite public static class ...

  7. python:split()函数

    描述 Python 内置函数 指定分隔符对字符串进行切片 如果参数 num 有指定值,则仅分隔 num 个子字符串 返回分割后的字符串列表. 语法 str.split(str="" ...

  8. 强大的开源企业级数据库监控利器Lepus

    Lepus监控简单介绍 官方网站:http://www.lepus.cc 开源企业级数据库监控系统 简洁.直观.强大的开源数据库监控系统,MySQL/Oracle/MongoDB/Redis一站式性能 ...

  9. 使用fiddler进程弱网测试

    使用fiddler手机需调整所连网络代理模式为手动,主机名与端口改为与电脑相同 打开Fiddler,Rules(规则)->Performance(性能)->勾选 Simulate Mode ...

  10. 19 Python之面向对象(成员)

    1. 成员 在类中你能写的所有内容都是类的成员 2. 变量 1. 实例变量: 由对象去访问的变量. class Person: def __init__(self, name, id, gender, ...