Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Web Developer

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Your profile

    Search

    XML Feeds

    Google Ads

    « Trying out Gibraltar's Loupe with NancyNancy, IIS 7 and the PUT command »
    comments

    No, not that.

    I had the need to write documentation for my services. I thought having them as html would be nice and good enough.

    So I made a bunch of vbhtml razorviews because I want my pages to be pretty and use the masterpage I already made for my main site. You know, to be consistent.

    So I had this.

    • page1.vbhtml
    • page2.vbhtml
    • page3.vbhtml
    • page4.vbhtml
    • index.vbhtml

    And to show those pages I just have this in my module.

    1. MyBase.Get("/{Title}") = Function(parameters)
    2.   Return Negotiate.WithView("documentation/" & parameters.Title)
    3. End If

    So calling page1 is as easy as

    /documentation/page1

    But what if someone did

    /documentation/page12

    They would get an error.

    But, meh, I don't want that. I want them to return to the index instead.

    So here is my solution.

    1. Public Sub New(viewlocator As IViewLocator)
    2.             MyBase.New("/documentation")
    3.             MyBase.Get("/{Title}") = Function(parameters)
    4.                                          If viewlocator.LocateView("documentation/" & parameters.Title, Context) IsNot Nothing Then
    5.                                              Return Negotiate.WithView("documentation/" & parameters.Title)
    6.                                          Else
    7.                                              Return Negotiate.WithView("documentation/index")
    8.                                          End If
    9.                                      End Function

    With help from GrumpyDev.

    Quick and easy.

    I do not want to put to much work in the documentation since noone will ever read it anyway.

    About the Author

    User bio imageChris is awesome.
    Social SitingsTwitterHomePageLTD RSS Feed
    nancy, vb.net
    InstapaperVote on HN

    No feedback yet

    Leave a comment


    Your email address will not be revealed on this site.

    To mislead the spambots.

    Your URL will be displayed.
    (Line breaks become <br />)
    (Name, email & website)
    (Allow users to contact you through a message form (your email will not be revealed.)