WebApi 空專案建立WebApi工程步驟

2021-09-14 00:28:15 字數 2318 閱讀 2834

1 新建空的asp.net應用程式

3 在工程下面建controller和models資料夾

4 在models資料夾下面新建類 storage

using system;

using system.collections.generic;

using system.linq;

using system.web;

namespace manualwebapi.models

public static ienumerableteachers

static storage()

,new student(),

new student(),

new student(),

new student(),

};teachers = new list();}}

public class person

public string name

public int age

public bool gender

}public class student:person

}5 在controller資料夾下面建studentscontroller類,讓其繼承於apicontrollerr

6  新建全域性檔案global.asax,增加路由

7 執行,在位址列輸入http://localhost:56982/api/students,開啟postman輸入**則得到json資料

8 輸入http://localhost:56982/api/students/zs1 測試get方法

9.選擇post,在body裡面輸入資料,測試post方法

10 選擇delete, 輸入http://localhost:56982/api/students/zs1 ,傳送命令後再執行get來測試delete方法

11 選擇put,輸入http://localhost:56982/api/students/zs2,body裡面輸入新的資料,傳送命令後,再執行get,測試put方法

json資料[,

,,,]

iOS UI 建立空專案

一 建立工程 二 刪除viewcontroller 三 在supporting files info.plist檔案中清空值 四 建立新的控制器 五 寫 1 import 2 import firstviewcontroller.h 3 46 property strong,nonatomic ui...

webapi 可空引數

這裡上面是乙個可空引數的例子。請不要寫成 public wapoutgoingresponse gettaskpatrolhistory string user,datetime?start,datetime?end int?count,int?since 一開始我是這麼寫的,但是在呼叫的時候發現 ...

從空專案建立MFC工程

好多教程都漏了一項,導致我一直黑框。我的環境 win7 vs2012,不過這個應該都差不多吧。1.從visual c 中選擇新增乙個空專案 2.在專案屬性 配置屬性 鏈結器 系統 子系統中選擇windows 否則就會只出黑視窗 3.在專案屬性 配置屬性 常規 專案預設值 mfc的使用一欄中,選擇使用...