Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

274
Vistas
Asp.Net Core MVC Routing like Express?

I've used Express (web development framework for node.js) routers and like the routing style. Below an example of some routes.

apiRouter.get("/project/:id",auth.verifyEditor,routes.getProject);
apiRouter.put("/project",auth.verifyEditor,routes.updateProject);
apiRouter.delete("/project/:id",auth.verifyEditor,routes.deleteProject);
apiRouter.get("/project/:id/page/:pageId", auth.verifyEditor,auth.verifyEditor, routes.getPage);
apiRouter.get("/project/:id/page",auth.verifyEditor,routes.getPages);
apiRouter.put("/project/:id/page",auth.verifyEditor,routes.updatePage);

It defines routes with verb (like .get( ... )), route (/project)and route-params (:id), middleware (auth.verifyEditor) and the handler (routes.updatePage) What I like most of this style is

  • The routes are defined centralized
  • The precedence of routes is clear: reading from above the first match is used
  • The mapping to handlers is unambiguous and above all: coded, so it will take advantage of intellisense, refactoring, and error checking at compilation time.

Routing in Asp.Net MVC is accomplished in many (and more elaborate) ways like attribute routing. Some aspects make this routing style less appealing to me:

  • Attribute routing is decentralized, so cannot be easily managed (doubles or omissions in routes)
  • Template based routing is based on parsed strings, so there's no way to use intellisense, refactoring or compile time error checking (though at startup some problems are reported)
  • Templates with {controller} and {action} parameters are IMO to greedy and error prone (if not a security risk)
  • Reading and interpreting routes is not easy (especially with constraints and regexps)

I know it's possible to define explicit routes like:

routes.MapRoute(name:"CustomerList", template:"api/customer",defaults: new { controller = "Customer", action = "Get" }); 

But I'm not sure that's like swimming against the tide and I don't know the impact on performance.

Therefor my question: is there a more Express-like routing style possible and feasible in Asp.Net? Or would you suggest an other approach (preferably with key aspects "centralized", "not string-based")

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda