ASP.NET Web API

-web-api

#web-api

Table of Contents

About

1

Chapter 1: Getting started with -web-api

2

Remarks

2

Examples

2

Installation or Setup

2

What and Why Web API ?

2

To add Web API to an existing MVC application.

2

Chapter 2: Web API Content Negotiation

Examples

4

4

Web API Content Negotiation Basic Information

4

Content Negotiation in Web API

5

Understanding the concept

5

A practical example

6

How to configure in Web API

6

Chapter 3: WEB API CORS Enabling

Examples

8

8

Enabling CORS for WebAPI 2

8

Enabling CORS globally for Web API 2

8

Enabling CORS in 5 for all domains and methods

8

Enabling CORS in 5 for specific domains and methods

8

Configure CORS for WebAPI 2 with Windows Authentication

9

Properly send authenticated request from jQuery against Web API 2 endpoint

10

Properly send authenticated request from AngularJS against Web API 2 endpoint

11

Chapter 4: Web API MediaTypeFormatter

Examples

13

13

MediaTypeFormatter Basic Information

13

Chapter 5: Attribute Routing in WebAPI

16

Introduction

16

Syntax

16

Parameters

16

Remarks

16

Examples

16

Basic Attribute Routing

16

Route Prefix Attribute

17

Chapter 6: Caching

18

Remarks

18

Examples

18

System.Runtime.Caching (MemoryCache)

Chapter 7: Configure a Web API application to respond with pretty/formatted JSON data by d

Examples

Default JSON formatting: Efficiency at the cost of readability

Chapter 8: Creating A Custom ActionFilterAttribute

18

20

20

20

22

Introduction

22

Examples

22

EnsurePresenseOfAttribute

22

Controller Before EnsuresPresenseOf Attribute

23

Update Controller

23

Chapter 9: OData with Web API

Examples

25

25

Install the OData Packages

25

Enable Entity Framework

25

Configure the OData Endpoint

26

Add the OData Controller

27

Performing CRUD on the Entity Set

27

Querying the Entity Set

27

Adding an Entity to the Entity Set

28

Updating an Entity

28

Deleting an Entity

29

Chapter 10: Quick Start: Working with JSON

31

Remarks

31

Examples

31

Return JSON from GET using attributes

31

1. Setup your formatter and routing in Register of (App_Start/WebApiConfig)

31

2. Create methods in an ApiController

31

Chapter 11: Web API Url Routing

33

Examples

33

How Routing works in webapi

33

Verb based routing examples.

35

Credits

37

About

You can share this PDF with anyone you feel could benefit from it, downloaded the latest version

from: asp-net-web-api

It is an unofficial and free -web-api ebook created for educational purposes. All the content

is extracted from Stack Overflow Documentation, which is written by many hardworking individuals

at Stack Overflow. It is neither affiliated with Stack Overflow nor official -web-api.

The content is released under Creative Commons BY-SA, and the list of contributors to each

chapter are provided in the credits section at the end of this book. Images may be copyright of

their respective owners unless otherwise specified. All trademarks and registered trademarks are

the property of their respective company owners.

Use the content presented in this book at your own risk; it is not guaranteed to be correct nor

accurate, please send your feedback and corrections to info@



1

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download