Nancy 框架

轻量级web框架,基于.net (mono), 不依赖于asp.net,

可以多宿主(自宿主,asp.net宿主, owin,Kestrel等) 

非常方便,小巧,好用。

 

https://github.com/NancyFx/Nancy

http://www.80iter.com/blog/1448933882755850

http://www.cnblogs.com/WhyShang/p/4107114.html 

 

View里直接写Model.property,不用申明类型,模板写xxx.hmtl

有列表类型的,用cshtml文件,申明类型为动态即可,比较像tornado模板

 

@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<dynamic>

    @foreach (var module in @Model) {
        <li>@module.title</li>
    }
public HomeModule()
        {
            Get["/api/customer"] = p => { return "hello, this is a nancy web."; };

            Get["view/book"] = p => { return View["book.html", new { title = "python006", price = 59 }]; };

            Get["view/list"] = p => { return View["list", BLL.booklist()]; };

            Get["view/pid"] = p => getReq();
        }

        public dynamic getReq()
        {
            string pid = Request.Query["pid"];
            //Request.Files;
            return pid;
        }

 

注:关于asp.net mvc, web api

vs new asp.net web项目,选择.net 4.5或以上,empty模板,选择mvc or web api

posted @ 2017-02-10 16:36  chy710  阅读(82)  评论(0)    收藏  举报