Introduction

A few hours ago I started [a website in Nancy][1]. Now I want to show data I have in my webpage.

And here the docs were not all that helpfull. But I made it.

The Model

First of all I need a Model.

Namespace Model
    Public Class PlantsModel
        Public Property Id As Integer
        Public Property Name As String
        Public Property LatinName As String
    End Class
End Namespace```
And I put that in a Model folder. I ended with Model since that is the convention but not really needed in all cases.

## The View

Time to move on to more exiting things.

I created a Plants.html file.

```html
<!DOCTYPE html>
<html>
<head>
    <title>NancyFX</title>
</head>
<body>
    <h1>Plants</h1>
    <div id="plants">
        <p>@Model.Id</p>
        <p>@Model.Name</p>
    </div>
</body>
</html>
    ```
I used the [SuperSimpleViewEngine][2] for this.

As you see I just add the @Model. and then the name of the property I want. Simples.

Now I just need to tell my controller what to do.

## The Controller

I guess we can call our module our controller.

```vbnet
Imports WebApplication2.Model
Imports Nancy

Public Class PlantsModule
    Inherits NancyModule

    Public Sub New()
        MyBase.Get("/plants") = Function(parameters)
                                    Return View(New PlantsModel() With {.Id = 2, .Name = "test"})
                                End Function

    End Sub

End Class```
So the url http://localhost/plants will take you to the page Plants.htmland will inject the PlantsModel I just created in there. By convention the fact that you inject a PlanstModel in there informs Nancy that you want to use the Plant.html view. 

You could have written this instead.

```vbnet
Imports WebApplication2.Model
Imports Nancy

Public Class PlantsModule
    Inherits NancyModule

    Public Sub New()
        MyBase.Get("/plants") = Function(parameters)
                                    Return View("Plants.html", New PlantsModel() With {.Id = 2, .Name = "test"})
                                End Function

    End Sub

End Class```
Or any other html.

And that gives us this amazing page.

<div class="image_block">
  <a href="https://lessthandot.z19.web.core.windows.net/wp-content/uploads/users/chrissie1/nancy/nancy5.png?mtime=1355234722"><img alt="" src="https://lessthandot.z19.web.core.windows.net/wp-content/uploads/users/chrissie1/nancy/nancy5.png?mtime=1355234722" width="230" height="243" /></a>
</div>

## Conclusion

Slightly harder than it should have been because I could not find the correct docs that explained this simply. But I got it working anyway.

 [1]: /index.php/WebDev/ServerProgramming/ASPNET/nancy-and-vb-net
 [2]: https://github.com/NancyFx/Nancy/wiki/View-engines