摘要: 创建接口 where T:class 指定T只能是类型 public interface ITest<T> where T:class { IEnumerable<T> GetAll(); } 实现: public class TestClass : ITest<Factory> { public 阅读全文
posted @ 2020-10-28 23:52 李花花小番茄 阅读(848) 评论(0) 推荐(0) 编辑
摘要: 再控制器方法中可以使用this.HttpContext.~~~来查询请求的信息(不推荐在方法中直接使用:不利于单元测试) 返回类型为IActionResult类型(实际上返回的类型是ContentResult(ContentResult实现了IActionResult接口)) 为什么要返回类型为IA 阅读全文
posted @ 2020-10-28 23:01 李花花小番茄 阅读(45) 评论(0) 推荐(0) 编辑
摘要: Arrtribute Routing 属性标签路由 使用控制器名称+控制器方法名路由 当然你也可以修改成[Route("v2/[controller]")]等 访问的时候就要在后面添加 /v2/Product/Production namespace TestMvc.Controllers { [R 阅读全文
posted @ 2020-10-28 22:41 李花花小番茄 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 以前有 Partial View,但是无法包含业务逻辑 Controller 里的逻辑也无法复用 View Component 的优势: ● 相当于带着小型 Controller 的 Partial View ● 适用于较复杂业务 ● 可使用 Razor 语法 定义: </font size = 5 阅读全文
posted @ 2020-10-28 15:43 李花花小番茄 阅读(98) 评论(0) 推荐(0) 编辑