mccalltd / AttributeRouting

Define your routes using attributes on actions in ASP.NET MVC and Web API.
http://mccalltd.github.io/AttributeRouting/
MIT License
416 stars 89 forks source link

EnumValueRouteConstraint and Null Value Problem #235

Open mdmoura opened 11 years ago

mdmoura commented 11 years ago

Hello,

I have the following action:

[GET("Notes?{p:int:min(1)}&{t:notetype?}")]
public virtual ActionResult Index(Int32 p = 1, Int32? t = null) {
}

And the following on my configuration:

x.InlineRouteConstraints.Add("notetype", typeof(EnumValueRouteConstraint<NoteType>));

But I am still able to access "/notes?p=1&t=12"

This shouldn't be possible since NoteEnum only has 3 values: 1, 2 and 3.

If I change {t:notetype?} to {t:notetype} then the notetype constraint works.

However, t does not accept the null value.

Thank You, Miguel