Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC 3: can I combine C# Razor Views with F# Controllers?

I figure this is a straight forward question, and I think there is a good chance the answer is "yes" (while mixed-language projects are generally not possible, it seems to me that the View Engine gets special treatment). I know I could also try this out pretty easily myself, but for the record, and to save myself some time, I'd like to know if this combination is possible (I've not used ASP.NET MVC or Razor myself yet, I'm considering options for a new project at work).

Edit: I am particularly interested in whether this combination is possible within a single project. Or more specifically whether there are any feature losses using this combination (even if the two project setup is the way to go).

like image 896
Stephen Swensen Avatar asked May 04 '11 13:05

Stephen Swensen


1 Answers

You can definitely mix a C# Razor code with F# controllers. It may be possible to do this in a single project (by modifying the web project to use F#). An easier alternative is to create a standard C# Razor Web project and a separate F# project (containing model and controller code).

I created a Visual Studio template that allows you to do exactly this.

Unfortunatelly, the template is not yet available on Visual Studio Gallery (so you cannot see it from "Online Templates" tab in "New Project" dialog). There is some issue with their upload mechanism, that I'm trying to resolve, so it should hopefully appear there soon. There are also several ASP.NET MVC templates by Daniel Mohl on Visual Studio Gallery, but I'm not sure if any of them uses Razor.

like image 95
Tomas Petricek Avatar answered Sep 28 '22 03:09

Tomas Petricek