ASP.NET MVC F# controller action ignoring parameter
- by Matt H
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?