惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 如是如是

将博客搬至CSDN 钱钟书夫人杨绛:《一百岁感言》 DOM无关事件 用到了反射,还不错。可以取到动态创建类的值 JounceTabRegion Jounce Blendable RestShart Post 方式传递poco给Web api Using ASP.NET Web API with ASP.NET Web Forms ASP.NET Web API MVC-REST-SilverLight 之 架构 MVC-REST-SilverLight 之 RestExample.Model.Silverlight\Customer.cs - 如是如是 MVC-REST-SilverLight 之MainPage.xaml.cs MVC-REST-SilverLight 之 ViewModels\MainViewModel.cs - 如是如是 MVC-REST-SilverLight 之Api\CustomerApi.cs - 如是如是 - 博客园 MVC-REST-SilverLight 之 Global.asax.cs MVC-REST-SilverLight 之 HttpConfiguration MVC-REST-SilverLight 之 MapServiceRoute MEF Export 和 Import 委托 设计模式-访问者
How to Migrate from WCF Web API to ASP.NET Web API
如是如是 · 2012-03-07 · via 博客园 - 如是如是

Introduction

We recently announced that WCF Web API is now ASP.NET Web API. This document provides guidance on how to migrate your existing WCF Web API code to ASP.NET Web API.

Overview

The WCF Web API abstractions map to ASP.NET Web API roughly as follows

WCF Web API

ASP.NET Web API

Service

Web API controller

Operation

Action

Service contract

Not applicable

Endpoint

Not applicable

URI templates

ASP.NET Routing

Message handlers

Same

Formatters

Same

Operation handlers

Filters, model binders

Web API Controllers

Update you service types to be web API controllers by first deriving from ApiController and renaming your service type so that the type name ends with "Controller".

Routing

You can directly map URI templates to routes by defining a route that matches the URI template path and then specifying the method name as the default value for the action route variable. The approach will result in one route per action, which depending on the number of actions may result in significant performance overhead.

To consolidate the number of routes consider refactoring your service so that there is one web API controller per resource.

 Model Binding

Model binding is a powerful feature in ASP.NET MVC (and on its way to Web Forms in ASP.NET 4.5 too). It allows you to write a method that accepts your custom object type as a parameter, and ASP.NET Web API handles mapping posted data to that parameter. It lets you focus on implementing your specifications and get out of the business of mindless (and error prone) mapping code. Here's an example, showing how a method that accepts posted data can focus on the logic of handling the data:

?

1

2

3

4

5

6

7

public HttpResponseMessage<comment> PostComment(Comment comment) 

{

    comment = repository.Add(comment);

    var response = new HttpResponseMessage<comment>(comment, HttpStatusCode.Created);

    response.Headers.Location = new Uri(Request.RequestUri, "/api/comments/" + comment.ID.ToString());

    return response;

}

Filters

Filters are a really powerful feature in ASP.NET MVC. You can use attributes to apply pre/post logic to action methods, entire controllers, or globally to all action methods. They're available in ASP.NET Web API as well, and you use the same kind of logic to both build and apply them. I worked with a sample that applied some custom attribute based validation using a global action filter, and found it really to apply my ASP.NET MVC background.