ASP.NET MVC F# controller action ignoring parameter

Posted by Matt H on Stack Overflow See other posts from Stack Overflow or by Matt H
Published on 2010-05-03T01:01:58Z Indexed on 2010/05/03 1:08 UTC
Read the original article Hit count: 376

Filed under:
|
|
|
|

Hi.

I have a C# ASP.NET MVC project but my controllers are written in F#.

For some reason, the following code doesn't work properly.

namespace MvcApplication8.Controllers

open System.Web.Mvc

[<HandleError>]
type ImageController() =
  inherit Controller()

  member x.Index (i : int) : ActionResult =
    x.Response.Write i
    x.View() :> ActionResult

The parameter of the action is seemingly ignored.

http://localhost:56631/Image/Index/1

=>

The parameters dictionary contains a null entry for parameter 'i' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Index(Int32)' in 'MvcApplication8.Controllers.ImageController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters     

The controller otherwise works fine. I know that plenty of people have written F# mvc code, so, any ideas where I'm going wrong?

© Stack Overflow or respective owner

Related posts about F#

Related posts about ASP.NET