前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Fd.Service 轻量级WebApi框架

Fd.Service 轻量级WebApi框架

作者头像
蘑菇先生
发布2018-05-21 17:18:36
7320
发布2018-05-21 17:18:36
举报

News

December 06 2014: Version 1.0.0.8 Add Register Route 

Configuration

iis 7 Integrated Mode:

代码语言:javascript
复制
<system.webServer>
    <modules>
     <add name="UrlRoutingModule" type="FD.Service.UrlRoutingModule,FD.Service"/>
    </modules>
</system.webServer>

iis 6

代码语言:javascript
复制
<system.web>
 <httpModules>
  <add name="UrlRoutingModule" type="FD.Service.UrlRoutingModule,FD.Service"/>
 </httpModules>
</system.web>

Register Service and Route on Global.asax

代码语言:javascript
复制
 protected void Application_Start(object sender, EventArgs e)
        {
            FdRouteTable.RegisterService("FdServiceTest");

            FdRouteTable.RegisterRoute(
                name: "Default",
                url: "api/{controller}/{action}"
                );
        }

Usage

API Statement:

代码语言:javascript
复制
[FdService(SessionMode = SessionMode.Support, IsPublicAllMethod = true)]
[Auth(Message="Login Authorization")]
public class SchoolApi
{      
        [FdMethod]
        [Auth(Order = 1, Message = "Authorization")]
        [log(Order = 2, Message = "Log Record")]
        public static int GetPointsByID(int id)
        {
            return 10;
        }
        [FdMethod(ResponseFormat = ResponseFormat.Json)]
        public static List<Student> GetStudentList()
        {
            return new List<Student>()
            {
                new Student()
                {
                    Age = 13,
                    Name = "LOKI"
                },
                new Student()
                {
                    Age = 14,
                    Name = "Frigga"
                }
            };
        }
}

Client invoke:

代码语言:javascript
复制
$.get("/api/SchoolApi/GetPointsByID/", { sid: 101, id: 100 }, function (data) {
            $("#textDetail").append("<br/>GetPointsByID:" + data);
 });

Installation

FD.Service can be installed via the nuget UI (as FD.Service), or via the nuget package manager console:

PM> Install-Package FD.Service

开源地址:

https://github.com/mushroomsir/FD.Service

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014-03-08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • News
  • Configuration
    • iis 7 Integrated Mode:
      • iis 6
      • Register Service and Route on Global.asax
      • Usage
        • API Statement:
          • Client invoke:
          • Installation
          • 开源地址:
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档