WEB API
Web-API
https://restfulapi.net/rest-put-vs-post/
Header tags Fiddler
Accept: text/html
Content-Type: application/xml
CORS:
Install-Package Microsoft.AspNet.WebApi.Cors
To enable for all controllers then add below two line in route config.
EnableCorsAttribute cors = new EnableCorsAttribute("*","*","*");
config.EnableCors(cors);
To enable CORS for a specific controller then
add namespace System.Web.Http.Cors and add this attribute above the controller [EnableCors("*","*","*")]
To disable CORS then use [DisableCors] attribute.
EnableCors attributes
Origins - http://localhost:123/
Headers - Content-Type (json or xml)
Methods - GET,PUT, ...
To Enable https in Visual Studio
Import localhost certificate MMC and export to trusted certificates
To Enable Asp.net WEB API
link
IHttpActionResult vs HttpResponseMessage
If we are calling the webapi service from JQuery then we need to Keep the access token in sessionstorage. sessionstorage is like a dictionary. If we want logoff from webapi then we need to remove the accesstoken item from sessionstorage.
======================================================================
https://restfulapi.net/rest-put-vs-post/
Header tags Fiddler
Accept: text/html
Content-Type: application/xml
CORS:
Install-Package Microsoft.AspNet.WebApi.Cors
To enable for all controllers then add below two line in route config.
EnableCorsAttribute cors = new EnableCorsAttribute("*","*","*");
config.EnableCors(cors);
To enable CORS for a specific controller then
add namespace System.Web.Http.Cors and add this attribute above the controller [EnableCors("*","*","*")]
To disable CORS then use [DisableCors] attribute.
EnableCors attributes
Origins - http://localhost:123/
Headers - Content-Type (json or xml)
Methods - GET,PUT, ...
To Enable https in Visual Studio
Import localhost certificate MMC and export to trusted certificates
To Enable Asp.net WEB API
link
IHttpActionResult vs HttpResponseMessage
If we are calling the webapi service from JQuery then we need to Keep the access token in sessionstorage. sessionstorage is like a dictionary. If we want logoff from webapi then we need to remove the accesstoken item from sessionstorage.
======================================================================
Creating Help Pages for ASP.NET Web API
By default WebAPI returns JSON data if not specified Accept Header
Interview Questions
ihttpactionresult-vs-httpresponsemessage
Token Based Authentication Using ASP.Net Web API, OWIN and Identity With Entity Framework
Oauth vs OpenID
Add formatters to avoid errors in webpi.config
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings
.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
GlobalConfiguration.Configuration.Formatters
.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
Error:
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json;
Solution:
Add below lines of code in global.asax file.
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings .ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; GlobalConfiguration.Configuration.Formatters .Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
Role based web api
WebAPI Security
Integrate Azure AD B2C with ASP.NET MVC Web App – Part 3
Secure ASP.NET Web API 2 using Azure AD B2C – Part 2
Azure Active Directory B2C Overview and Policies Management – Part 1
ASP.NET Web API Claims Authorization with ASP.NET Identity 2.1 – Part 5
ASP.NET Identity 2.1 Accounts Confirmation, and Password Policy Configuration – Part 2
*****************************************************************************
Web API Role based authorization
Token Based Authentication using ASP.NET Web API 2, Owin, and Identity
Below topics are present in this article
- AngularJS Token Authentication using ASP.NET Web API 2, Owin, and ASP.NET Identity – Part 2.
- Enable OAuth Refresh Tokens in AngularJS App using ASP .NET Web API 2, and Owin – Part 3.
- ASP.NET Web API 2 external logins with Facebook and Google in AngularJS app – Part 4.
- Decouple OWIN Authorization Server from Resource Server – Part 5.
WEBAPI Interview questions
No comments:
Post a Comment