mvc 创建一个规则 route

    技术2025-02-02  16

    Dictionary<string, object> defaultDict = new Dictionary<string, object>(); defaultDict["action"] = "Index"; defaultDict["id"] = 0; RouteValueDictionary defaultRouteValue = new RouteValueDictionary(defaultDict); RouteValueDictionary constraintRouteValue = new RouteValueDictionary(); constraintRouteValue["controller"] = @"^/w+"; constraintRouteValue["id"] = @"/d+"; Route route = new Route("{controller}/{action}/{id}",defaultRouteValue,constraintRouteValue,new MvcRouteHandler()); routes.Add(route); 

     

     

    从以上代码我认识到了一个字典是如何使用的,asp.net中的大部分的类都是实现接口的,所以要把接口的相关知识学习好。

    最新回复(0)