Reputation: 91
This is the line that is not working:
ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder())
To be more precise. Binders is highlated.
I found this article by Phil Haack.
I did all it said, added refrences to using System.Web.Http.ModelBinding.Binders;
Added class public class DecimalModelBinder : IModelBinder
to a new folder and told to Global.ascx about the folder. But the red line keeps showing underneath the Binders. Can you help me?
Upvotes: 0
Views: 1123
Reputation: 13266
From the error it looks like it is treating the ModelBinders
as namespace (which is present in your project) instead of the framework class.
Try using the below line which will resolve the ambiguity.
System.Web.Mvc.ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder())
Upvotes: 5
Reputation: 976
The compiler interprets the reference to ModelBinders as a reference to RoomReservation.Wep.ModelBinders. Try using
System.Web.Http.ModelBinding.Binders.Add(typeof(decimal), new DecimalModelBinder())
Upvotes: 0