I have a controller called Diary with an action called View.
If I receive a URL in the form “Diary/2012/6” I want it to call the View action with year = 2012 and month = 6.
If I receive a URL in the form “Diary” I want it to call the View action with year = [current year] and month = [current month number].
How would I configure the routing?
In your routes, you can use the following:
If year/month are not provided, the current values will be sent. If they are provided, then those values will be used by the route.
1976, month = 4
EDIT
In addition to the comment below, this is the code used to create a new project using the above criteria.
Global.Asax
DairyController
The View
Results: