
- 1、类继承路由对象IRouteConstraint实现一个路由逻辑
- public class RouteConstraint : IRouteConstraint
- {
- public bool Match(HttpContext httpContext, IRouter route, string routeKey, RouteValueDictionary values, RouteDirection routeDirection)
- {
- if (int.TryParse(values["is"].ToString(), out int id))
- {
- if (id % 2 == 0)
- {
- return true;
- }
- }
- return false;
- }
- }
- 在中间件启动服务
- services.Configure<RouteOptions>(a =>
- {
- //如果url查询字符串为小写,将LowercaseUrls设置为true,默认为false;
- a.LowercaseUrls = true;
- //同时LowercaseQueryStrings也需要设置为true,默认为false
- a.LowercaseQueryStrings = true;
- //生成的url后面附加一个斜杠
- a.AppendTrailingSlash = true;
- a.ConstraintMap.Add("even", typeof(RouteConstraint));
- });
由于这里没有设置生成连接数据库所以直接会是视图文件
这里有个小问题不能设置于首页不然打不开
评价
排名
11
文章
201
粉丝
10
评论
13
EF连接MySQL连接MySQL数据库操作中文数据乱码解决方法
剑轩 :
准确点应该是ef连接mysql
Layui插件上传图片具体步奏以及获取图片地址
风清月 : 厉害老!
Action与Func的用法-----委托
剑轩 : 可以可以
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术