Lightweight web Framework--nancy

Source: Internet
Author: User

    1. Nancy official website--https://github.com/nancyfx/nancy
    2. Overview: Nancy is an open source Web lightweight framework kernel that conforms to the MVC concept, has the features of easy development, simple routing, and is fully functional
    3. Start: Hellow World

I. Creating an ASP. NET Web Application

Two. Add a reference to the Nancy package using NuGet

Three. Add a reference to Nancy

Add the above two to use Nancy to build the application, such as some small interface, the following article will give this application

If you need a page, then you need a view engine, Nancy has built multiple view engines for us, and I've used only two of them so far.

1 "Spark

2 "Razor

There are a lot of differences between the two view engine syntax, which are all, but razor is more appropriate if you are using VS for development.

Add Razor View engine

OK to this environment, the Code (note: You must establish the Views folder in the project root directory, Nancy lookup view by default from the file)

 Public class Hellomodule:nancymodule    {        public  hellomodule ()        {            get["/hello"] = p = =                 {                    return view["Hello"];}                ;     }

Project structure:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.