action = "Index|About|Contact", that will prevent the handling, and URL generation, of non-existing actions. The framework only needs a string, from a list of valid values.Declarative Programming
Saturday, May 18, 2013
ASP.NET Routing: Regex Constraints are inneficient
There are cases where using Regex constraints makes sense and does the job. For example, for action and controller parameters. If you have a constraint like
Labels:
asp.net,
asp.net mvc,
routing
Thursday, April 18, 2013
Delegate-based strongly-typed URL generation in ASP.NET MVC
The standard way of generating URLs in ASP.NET MVC involves hard-coding action, controller and parameter names:
string url = Url.Action("Edit", new { id = 5 });You are probably familiar with the expression tree-based strongly-typed URL generation approach, which is part of the MvcFutures library. It allows you to write code like this:
string url = Url.Action(() => Edit(5));
Labels:
asp.net mvc
Friday, March 29, 2013
Attribute-based routing coming to ASP.NET MVC and Web API v5
Attribute-based routing is coming to ASP.NET MVC and Web API, according to the roadmap. They are basing the solution on the popular AttributeRouting project. At the date of writing this post only Web API support is working, you can play with it by installing the nightly packages.
Labels:
asp.net mvc,
asp.net web api,
routing
Friday, February 8, 2013
Rethinking ASP.NET MVC: Workflow per Controller
My most controversial answer on StackOverflow is to a question about how to organize an ASP.NET MVC application. My answer was:
Labels:
asp.net mvc,
mvccoderouting,
patterns,
routing
Saturday, January 12, 2013
My life is an anti-pattern
For some reason people often look for THE solution to a particular problem, ignoring the fact that the best solution to any problem depends on its inputs. In other words, if someone asks you something there are two answers that are always correct: I don't know and it depends. These phrases probably won't help you much if you are a business man of a politician, but as programmers we should feel comfortable saying, specially the latter. Because, that IS what we do, right? Take some input, program some logic and return a result.
Labels:
patterns
Thursday, November 1, 2012
MvcPages: ASP.NET MVC without routes and controllers
I like developing with ASP.NET MVC, but sometimes I feel there are too many pieces involved. To develop a single function you have to (in no particular order):
- Create route (make sure it doesn't break other routes)
- Create controller/action
- Create view model
- Create view
return View()?
Labels:
asp.net mvc,
asp.net web pages,
mvcpages
Saturday, October 27, 2012
Implementing a contact form plugin for ASP.NET MVC
The purpose of this post is to demonstrate the patterns presented in the Patterns for ASP.NET MVC Plugins series so far.
- Routes, Controllers and Configuration
- View Models
- Demo: Implementing a contact form plugin
Labels:
asp.net mvc,
patterns,
plugin
Sunday, September 23, 2012
5 reasons why you should use MvcCodeRouting
MvcCodeRouting v1.0 is out, this post highlights the library's most important features and why I believe is a must have for all ASP.NET MVC developers.
Labels:
asp.net mvc,
mvccoderouting,
routing
Subscribe to:
Posts (Atom)