Saturday, December 8, 2012

Using the New ASP.NET MVC 4 Template in MonoDevelop

In my last post, I showed an example of an ASP.NET MVC 4 application built in MonoDevelop. Since that time, an ASP.NET MVC 4 project template has been created for MonoDevelop that makes it very easy to create a similar app.

Here are the steps for using this template:

1. To get started, install version 3.0.2+ of Mono, the latest version of MonoDevelop, and the F# Language Binding (through the MonoDevelop Add-in Manager). If you've already installed each of these, make sure that the F# Language Binding version is 3.2.8+.

2. Create a new solution (File | New | Solution) and select F# | ASP.NET | F# ASP.NET MVC 4 (Razor) as shown here:
3. Add the desired solution name, click OK, and your done.

Well that was easy, but where do you go from here? Let's walk through a simple example of creating an app for keeping track of contacts. The end result will be similar to the screenshot shown in my post entitled A Single Page App with Backbone.js, ASP.NET Web API, and F#.

1. I've already followed the previous steps to create an ASP.NET MVC 4 application in MonoDevelop called MyContacts. To quickly add a decent look to the app, I'll use the responsive front-end framework from ZURB called Foundation. All that I really need is the CSS, so I add the foundation.min.css file to the Content folder in the project. I also add an app.css file for any custom styles that are needed. The content of the app.css file is shown below:

2. I can now reference these CSS files in _Layout.cshtml. The modified file looks like this:

3. Now I modify the Index.cshtml file in the Home folder so that it will display the list of contacts. The result is shown below:

4. Lastly we make a few modifications to the HomeController. Here's the code:

5. That's it. We can now launch the site and see the following:






6 comments:

  1. why scala is so popular when f# is more friendly, more clear and asp mvc works really nice??..

    ReplyDelete
  2. This works well - created a website on the Mac with F# and MonoDevelop, easy.

    The only thing I had to do was change the v10.0 to v9.0 in the targets reference in the .fsproj file like the template says. If you don't do that you get a NullReferenceException when you build.

    ReplyDelete
  3. @andre2 Who cares? Perl is also more popular. F# is better, just enjoy it.

    ReplyDelete
  4. Any suggestions for this? http://stackoverflow.com/questions/30497900/how-to-use-url-action-in-mono

    ReplyDelete
  5. Hello there! This is kind of off topic but I need some advice from an established blog. Is it tough to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking about setting up my own but I'm not sure where to start. Do you have any points or suggestions? Appreciate it

    ReplyDelete
  6. I have been exploring for a bit for any high quality articles or weblog posts on this sort of area . Exploring in Yahoo I ultimately stumbled upon this site. Studying this information So i'm glad to express that I've a very good uncanny feeling I came upon just what I needed. I so much surely will make certain to do not disregard this web site and provides it a look on a constant basis.

    ReplyDelete