Error When Customizing MVC5 Routes

Asked

Viewed 38 times

2

Error occurs in method (Registerroutes) in Routeconfig.Cs on line

routes.MapMvcAttributeRoutes();

When running in the browser:

* The built-in Constraint resolver of type 'Defaultinlineconstrainaintresolver' could not resolve the following built-in Constraint: 'string'. *

[Httpexception (0x80004005): The built-in Constraint resolver of type 'Defaultinlineconstrainaintresolver' could not resolve the following built-in Constraint: 'string'.]
System.Web.Httpruntime.Firstrequestinit(Httpcontext context) +10042604 System.Web.Httpruntime.Ensurefirstrequestinit(Httpcontext context) +95 System.Web.Httpruntime.Processrequestnotificationprivate(Iis7workerrequest Wr, Httpcontext context) +254

1 answer

2


This error means that somewhere, on a Route, you specified something like

[Route("AlgumaRota/{algumparametro:string}")]

The restriction inline string is not required as it is already the assumed type coming from the URL. Including such restriction inline nor is available by DefaultInlineConstraintResolver, as the error tells you.

The section Route Constraints of that Article provides a table that lists all supported restrictions.

To resolve your problem, just remove the restriction string

[Route("AlgumaRota/{algumparametro}")]
  • Thank you, that’s exactly what it was

Browser other questions tagged

You are not signed in. Login or sign up in order to post.