0

我在 ASP.NET MVC 5 项目中有以下内容:

DefaultInlineConstraintResolver resolver = new DefaultInlineConstraintResolver();
resolver.ConstraintMap.Add("notetype", typeof(EnumConstraint<NoteType>));
RouteTable.Routes.MapMvcAttributeRoutes(resolver);
GlobalConfiguration.Configuration.MapHttpAttributeRoutes(resolver);

在最后一行,解析器在 MapHttpAttributeRoutes 上不被接受。我怎样才能做到这一点?

4

1 回答 1

0

尝试这个

DefaultInlineConstraintResolver resolver = new DefaultInlineConstraintResolver();
resolver.ConstraintMap.Add("notetype", typeof(EnumConstraint<NoteType>));
RouteTable.Routes.MapMvcAttributeRoutes(resolver);
GlobalConfiguration.Configuration.MapHttpAttributeRoutes(new HttpRouteBuilder(resolver));
于 2013-10-31T15:48:15.907 回答