摘要: 設定模型系結器 有幾種方式可以設定模型系結器。 首先,您可以將 [ModelBinder] 屬性加入至參數。 public HttpResponseMessage Get([ModelBinder(typeof(GeoPointModelBinder))] GeoPoint location) 您也 阅读全文
posted @ 2021-11-03 17:21 zq爱生活爱代码 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 需要引用using System.Net.Http; var cookies = actionContext.Request.Headers.GetCookies(); // API 推荐 HttpCookieCollection collection = HttpContext.Current.R 阅读全文
posted @ 2021-11-02 14:55 zq爱生活爱代码 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 传递实体对象,首先定义负责对象 public class Student { public string name { get; set; } public string sex { get; set; } public string age { get; set; } public Adress 阅读全文
posted @ 2021-11-01 17:23 zq爱生活爱代码 阅读(427) 评论(0) 推荐(0) 编辑
摘要: [HttpPost] // POST: api/EasyModelByRequestUrl public string Post(dynamic student) { return $"Post请求 姓名{student.name},性别{student.sex},年龄{student.age}"; 阅读全文
posted @ 2021-11-01 16:28 zq爱生活爱代码 阅读(208) 评论(0) 推荐(0) 编辑
摘要: action public class EasyModelByRequestUrlController : ApiController { // GET: api/EasyModelByRequestUrl [HttpGet] public string Action1(string name,st 阅读全文
posted @ 2021-11-01 14:39 zq爱生活爱代码 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 命名空间System.Net,WebClient是一种更高级别的抽象,是HttpWebRequest为了简化最常见任务而创建的,使用过程中你会发现他缺少基本的header,timeoust的设置,不过这些可以通过继承httpwebrequest来实现。相对来说,WebClient比WebReques 阅读全文
posted @ 2021-11-01 10:12 zq爱生活爱代码 阅读(209) 评论(0) 推荐(0) 编辑
摘要: //利用反射实现深拷贝 public static T DeepCopyByReflection<T>(this T tSource) { T tResult = Activator.CreateInstance<T>(); Type sourceType = typeof(T); Type res 阅读全文
posted @ 2021-11-01 08:55 zq爱生活爱代码 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Controller using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using Sy 阅读全文
posted @ 2021-10-24 11:59 zq爱生活爱代码 阅读(68) 评论(0) 推荐(0) 编辑
摘要: 约束的作用是 只有大写的参数值才能通过 一、定义约束 二、加载的时候引入约束 三、在controller 引入约束 using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; us 阅读全文
posted @ 2021-10-20 09:50 zq爱生活爱代码 阅读(35) 评论(0) 推荐(0) 编辑
摘要: <script> //輸入第一個字符的時間 var time1 = 0; var time2 = 0; var textLengthLast = 0; var inputEle = document.getElementById("txtData"); //禁止CtrlV inputEle.onke 阅读全文
posted @ 2021-09-13 19:02 zq爱生活爱代码 阅读(91) 评论(0) 推荐(0) 编辑