.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

MVC 3 and F#

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net

I'm developing a library for F# and have run into a couple of roadblocks along the way.

1)  The DefaultModelBinder checks the PropertyDescriptor IsReadOnly property with no way to override the check.  This creates a problem with binding F# records (which have readonly properties that can be set through reflection by overriding SetProperty).  I've worked around this by writing my own model binder for records, I just wish I hadn't had to go to the effort for something that should be easily done.

2)  FSharpOption<T> is like Nullable<T> (only it works for all types) but the MVC framework doesn't support them anywhere.  I created a model binder for Option types which works fine.  The issue is with the HtmlHelpers.  An example is given below:

<%= Html.TextBoxFor(a => a.DateOfBirth.ToShortDateString()) %>

using an extension method like:

        public static string ToShortDateString(this FSharpOption<DateTime> option)

More Related Resource Links

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend