asp.net webapi經驗分享

Download ASP.Net WebAPI經驗分享

Post on 12-Apr-2017

689 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

WebAPI

ASP.Net WebAPI

RESTWebAPIDebug WebAPIAsync/AwaitHttpClientHelp Page

RESTREST: REpresentational State TransferREST: RESTfullREST

RESTRoy Thomas Fielding

2000Architectural Styles and the Design of Network-based Software ArchitectureREST

Http:HeadGet Post Put Delete Patch OptionHttp:

HttpGetSelectPostInsertPutUpdateDeleteDeletePatchUpdate

(Resource),,

http://localhost/Products/1http://localhost/1(Internet);,Uri

HttpHttp/api/values:/api/values/1GetPutPostDelete

: Get http://localhost/api/valuesFirefox, Chrome ->XMLIE 10 ->JSon

Http Status CodeHttp,UI,Http Status Code

RESTWebAPIDebug WebAPIAsync/AwaitHttpClientHelp Page

WebAPIWebAPIWebAPI:Google Maps APIMediaWiki APIBing APIFacebook APIAPI

ASP.Net WebAPIASP.Net Web APIWCF Web APIASP.Net MVCWCFASP.Net WebAPIFrameworkHttp

ASP.Net WebAPIASP.Net MVCWCF Web APIASP.Net RoutingModern HTTP Programming ModelModel BindingHttpClientValidationTask-based asyncFiltersFormattingLink GenerationServer-side Query CompositionTestabilityCreate custom help pagesIoC IntegrationSelf-HostVisual Studio TemplateTracingScaffoldingContent Negotiation

ASP.Net WebAPIWCFASP.Net WebAPIHttpWCFSOA(Service-Oriented Architecture),:HttpASP.Net WebAPIWCF

ASP.Net WebAPIRouting

Get /api/valuesGet /api/values/1

ASP.Net WebAPIAPI: Http+ActionNameAPI: Http+UriCreate: Post api/valuesUpdate: PUT api/valuesRead: Get api/values Get api/values/5Delete: Delete api/values/5

ASP.Net WebAPIEntity FrameworkDatabaseClientASP.Net MVCASP.Net WebAPIEntity FrameworkHTMLJSonCRUDCRUD

Visual Studio

ASP.Net WebAPI-Northwind

Get

PUT

POST

Delete

Patch(Property),Put;PutNullPatchAction: [HttpPatch],: [Bind]

Patch

RESTWebAPIDebug WebAPIAsync/AwaitHttpClientHelp Page

Debug ASP.Net WebAPIASP.Net WebAPI,UI,Visual Studio 2010/2012IISExpress,IISExpressLog

POSTMan

ChromeApp StorePOSTMan

POSTManicon

PostmanOrder

POCO

!

IISExpressVisual Studio 2010IISExpress 7.5IISExpress,Windows XPVisual Studio 2012IISExpress 8.0IISExpress 8.0Windows XP

IISExpressconfig: C:\Users\{}\Documents\IISExpress\config\applicationhost.configconfig

Request

Fiddler

http://www.fiddlertool.com/fiddler2/version.asp

FiddlerIE

FiddlerASP.Net WebAPI

FiddlerPost

FiddlerPatch

RESTWebAPIDebug WebAPIAsync/AwaitHttpClientHelp Page

Async/Await.Net Framework 4.5:Async: Await: Async, 0 ~ AwaitAsync,: TaskAwaitIO Thread,Worker Thread

Async/Await::Await,

RESTWebAPIDebug WebAPIAsync/AwaitHttpClientHelp Page

Nuget

HttpClientRepositoryBase

:Client

:Order

RESTWebAPIDebug WebAPIAsync/AwaitHttpClientHelp Page

WebAPIHelp PageAPIAPIAPI(Help Page)Microsoft ASP.NET Web API Help PageNuget

CastleMicrosoft ASP.NET Web API Help PageCastle.NetAPIVisual StudioXMLCastleXMLAPI

:VS

XML:App_Data\XmlDocument.xml

: Help Page

3:

Help PageHelp PageWebAPI

RESTWebAPIDebug WebAPIAsync/AwaitHttpClientHelp Page

CORSCORSHTML5: