Fd.Service 轻量级WebApi框架

News

December 06 2014: Version 1.0.0.8
Add Register Route 

Configuration

iis 7 Integrated Mode:

<system.webServer>
    <modules>
     <add name="UrlRoutingModule" type="FD.Service.UrlRoutingModule,FD.Service"/>
    </modules>
</system.webServer>

iis 6

<system.web>
 <httpModules>
  <add name="UrlRoutingModule" type="FD.Service.UrlRoutingModule,FD.Service"/>
 </httpModules>
</system.web>

Register Service and Route on Global.asax

1
2
3
4
5
6
7
8
9
protected void Application_Start(object sender, EventArgs e)
       {
           FdRouteTable.RegisterService("FdServiceTest");
 
           FdRouteTable.RegisterRoute(
               name: "Default",
               url: "api/{controller}/{action}"
               );
       }

Usage

API Statement:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[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:

$.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

 

posted @   蘑菇先生  阅读(1546)  评论(4编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示