Chapter 21. ASP.NET MVC

WHAT'S IN THIS CHAPTER?

  • Building websites

  • Integrating C# views with F# controllers and models

  • Keeping concerns properly separated

  • Understanding the MVC pattern applied to F#

While F# is a strong contender in many areas of the development stack, it has not been traditionally thought of as a great candidate for development of code on the UI layer. This is especially true for platforms like WinForms, which promote a sense of statefulness that flows through not just the UI, but through the object model that a UI might be bound to. Most UI technologies of the WinForm era (including ASP.NET WebForms) are tied to the idea of mutating control objects as a core mechanism by which you promote interaction between a presentation object (MVP pattern) or ViewModel (MVVM pattern), and mutable UI objects (like controls with a .Text property). For such a stateful model, F# is merely an average OO language on the .NET framework, with no real compelling application besides being yet another language option.

For other models, however, that depend less on state maintenance — such as MVC frameworks — F# is far more compelling. In this chapter, you learn how to use F# with the ASP.NET MVC framework. We demonstrate an example of writing an ASP.NET MVC application that demonstrates how to use F# to simplify web development.

OVERVIEW

It is not that controversial to say that ASP.NET WebForms was designed in a manner to make web development "safe" for programmers from the world of Windows development, ...

Get Professional F# 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.