<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://skysigal.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://skysigal.com/feed.php">
        <title>Notes it:ad:asp.net:webapi:howto</title>
        <description></description>
        <link>https://skysigal.com/</link>
        <image rdf:resource="https://skysigal.com/lib/tpl/bootstrap3/images/favicon.ico" />
       <dc:date>2026-04-29T23:23:40+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/configure_max_message_size?rev=1699064142&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/create_a_controller?rev=1699064141&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/enable_attribute_routing?rev=1699064143&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/errors?rev=1699064143&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/home?rev=1699139836&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/how_to_define_client_certificates?rev=1699064144&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_delete_request_from_the_ui?rev=1699064145&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_get_request_from_the_ui?rev=1699064145&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_post_request_from_the_ui?rev=1699064147&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_put_request_from_the_ui?rev=1699064147&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_authorization?rev=1699064144&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_validation?rev=1699064148&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/post_a_file_using_ajax?rev=1699064148&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/replace_default_json_serializer?rev=1699064149&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/security?rev=1699064149&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/setup_ssl_security?rev=1699139837&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/use_odata_and_dtos?rev=1699064150&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/use_odata_on_webapi?rev=1699139837&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/using_external_authentication_services?rev=1699064150&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/version_services?rev=1699064151&amp;do=diff"/>
                <rdf:li rdf:resource="https://skysigal.com/it/ad/asp.net/webapi/howto/wif?rev=1699139838&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://skysigal.com/lib/tpl/bootstrap3/images/favicon.ico">
        <title>Notes</title>
        <link>https://skysigal.com/</link>
        <url>https://skysigal.com/lib/tpl/bootstrap3/images/favicon.ico</url>
    </image>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/configure_max_message_size?rev=1699064142&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:42+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Configure Max Message Size</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/configure_max_message_size?rev=1699064142&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Configure Max Message Size

	* (UP)
howto index



Configuration
&lt;configuration&gt;
  &lt;system.web&gt;
    &lt;httpRuntime maxRequestLength=&quot;16384&quot; requestLengthDiskThreshold=&quot;16384&quot;/&gt;
  &lt;/system.web&gt;
&lt;/configuration&gt;
Resources

	* SO</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/create_a_controller?rev=1699064141&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:41+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Create a Controller</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/create_a_controller?rev=1699064141&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Create a Controller

	* (UP)
howto index



Process

Installation in MVC3

	* It&#039;s part of MVC4 onwards, but for MVC3
		* Install-Package AspNetWebApi
		* Edit Global.asax.cs
			* Add using System.Web.Http;
			* Add a new route BEFORE the default catchall route.</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/enable_attribute_routing?rev=1699064143&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:43+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Enable Attribute Routing</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/enable_attribute_routing?rev=1699064143&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Enable Attribute Routing

	* (UP)
howto index



WebAPI1 only had Convention based Routing.

WebAPI2 added attribute based routing.

But it has to be turned on first.

Process



Resources

* &lt;http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2#prefixes&gt;</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/errors?rev=1699064143&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:43+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Errors</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/errors?rev=1699064143&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Errors

	* (UP)
howto index



Summary

Because it is a Web protocol we don&#039;t thro an exception -- we return a
 //Failed get
 throw new HttpResponseException(HttpStatusCode.NotFound); //etc.</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/home?rev=1699139836&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T23:17:16+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/home?rev=1699139836&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo

	* (UP)
howto index</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/how_to_define_client_certificates?rev=1699064144&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:44+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:How to define Client Certificates</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/how_to_define_client_certificates?rev=1699064144&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:How to define Client Certificates

	* (UP)
howto index



Solution
WebRequestHandler handler = new WebRequestHandler();
X509Certificate2 certificate = GetMyX509Certificate();
handler.ClientCertificates.Add(certificate); 
HttpClient client = new HttpClient(handler);</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_delete_request_from_the_ui?rev=1699064145&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:45+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Perform a DELETE request from the UI</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_delete_request_from_the_ui?rev=1699064145&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Perform a DELETE request from the UI

	* (UP)
howto index



##

ClientSide

Make a request:

	* using the more verbose $.ajax in order to specify the verb and statusCode map.
	* specifying the verb as DELETE
	* use statusCode to setup response handlers</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_get_request_from_the_ui?rev=1699064145&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:45+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Perform a GET request from the UI</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_get_request_from_the_ui?rev=1699064145&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Perform a GET request from the UI

	* (UP)
howto index



Process

Define a Server Side Controller action



Ref: IT:AD:HTTP/Response Codes

Response Codes

Suggested Response Codes are:
* 200: OK
* 401: (Not authorized). See why: http://stackoverflow.com/a/6937030/1052767
* 403: Forbidden (ie, Not Authorized). See why: http://stackoverflow.com/a/6937030/1052767
* 404: Not found
* 410: Gone</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_post_request_from_the_ui?rev=1699064147&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:47+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Perform a POST request from the UI</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_post_request_from_the_ui?rev=1699064147&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Perform a POST request from the UI

	* (UP)
howto index



Process

Server Side

We use HttpResponseMessage to

send back info in the right format (JSON, etc.)
include the right headers

Example:



Response Codes

	* HTTP 401: (Not authorized). See why:</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_put_request_from_the_ui?rev=1699064147&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:47+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Perform a PUT request from the UI</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/perform_a_put_request_from_the_ui?rev=1699064147&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Perform a PUT request from the UI

	* (UP)
howto index



Process

Server Side

We use HttpResponseMessage to

send back info in the right format (JSON, etc.)
include the right headers

Example:



Response Codes

	* HTTP 401: (Not authorized). See why:</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_authorization?rev=1699064144&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:44+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Perform Authorization</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/perform_authorization?rev=1699064144&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Perform Authorization

	* (UP)
howto index



Process

	* Authorize the whole Controller, or just a method within it, using the [AuthorizeAttribute]
	* As it is a Machine to Machine service, can&#039;t redirect -- have to send back either 200 or 401</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/perform_validation?rev=1699064148&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:48+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Validation</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/perform_validation?rev=1699064148&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Validation

	* (UP)
howto index



	* Most POC requests are scalar.
	* But once you get going, you should be using a RequestObject (some class with properties enough to describe the request).
	* As it is a class/object, once can use standard DataAnnotation (like Required, min/max length, etc.)</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/post_a_file_using_ajax?rev=1699064148&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:48+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:POST a file using Ajax</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/post_a_file_using_ajax?rev=1699064148&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:POST a file using Ajax

	* (UP)
howto index



Although IT:AD:ASP.NET:WebAPI makes it really easy to build a IT:AD:Single Page App (SPA), there is one small area where it really isn&#039;t as easy as it should be.

That&#039;s uploading a file.

Process

The following process involves client side html form, and server side code</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/replace_default_json_serializer?rev=1699064149&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:49+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Replace default JSON Serializer</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/replace_default_json_serializer?rev=1699064149&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Replace default JSON Serializer

	* (UP)
howto index



Some people don&#039;t like the default serializer

Solution

It can be replaced by one using json.net

Solution described here
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.IO;
using System.Web.Script.Serialization;
using System.Net;
 
namespace WebApiForTheMvcGuy.Formatter…</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/security?rev=1699064149&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:49+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Security</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/security?rev=1699064149&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Security

	* (UP)
howto index



Basics

	* WebAPI is REST.
	*  REST is stateless. 
		*  Therefore the client has to send an authentication every time.

* When the token expires -- as the Client Agent is probably a machine/proxy-- not a human</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/setup_ssl_security?rev=1699139837&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T23:17:17+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>it:ad:asp.net:webapi:howto:setup_ssl_security</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/setup_ssl_security?rev=1699139837&amp;do=diff</link>
        <description>http/pfelix.wordpress.com/2011/04/21/wcf-web-api-self-hosting-https-and-http-basic-authentication/</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/use_odata_and_dtos?rev=1699064150&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:50+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Use OData and DTOs</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/use_odata_and_dtos?rev=1699064150&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Use OData and DTOs

	* (UP)
howto index



Process

A key goal would be to use a Repository, returning DTO&#039;s to external services. That&#039;s a bit tougher.

	* The DataModel is defined in the Application Layer.
	* Use a DataMapper such as what we developed in XActLib (</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/use_odata_on_webapi?rev=1699139837&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T23:17:17+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>Process</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/use_odata_on_webapi?rev=1699139837&amp;do=diff</link>
        <description>Process

	* Change your API Controller from inheriting from the default System.Web.Http.ApiController to System.Web.Http.OData.ODataController:



Resources

	* http://blogs.msdn.com/b/webdev/archive/2013/01/29/getting-started-with-asp-net-webapi-odata-in-3-simple-steps.aspx</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/using_external_authentication_services?rev=1699064150&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:50+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Using External Authentication Services</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/using_external_authentication_services?rev=1699064150&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Using External Authentication Services

	* (UP)
howto index



No app that&#039;s wants to call itself secure should be persisting user name/password in the app&#039;s database -- use an external Authentication Service.

The social ones are important to resolve first. Or atleast know how to do offer them.</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/version_services?rev=1699064151&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T02:15:51+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>IT:AD:ASP.NET:WebAPI:HowTo:Version Services</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/version_services?rev=1699064151&amp;do=diff</link>
        <description>IT:AD:ASP.NET:WebAPI:HowTo:Version Services

	* (UP)
howto index



REST is about permanent network Resource addressing, whereas Versioning is about iterative updates. The two concepts are at odds with each other.

Versioning in REST can be achieved in the following ways:</description>
    </item>
    <item rdf:about="https://skysigal.com/it/ad/asp.net/webapi/howto/wif?rev=1699139838&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2023-11-04T23:17:18+00:00</dc:date>
        <dc:creator>Anonymous (anonymous@undisclosed.example.com)</dc:creator>
        <title>it:ad:asp.net:webapi:howto:wif</title>
        <link>https://skysigal.com/it/ad/asp.net/webapi/howto/wif?rev=1699139838&amp;do=diff</link>
        <description>&lt;https://github.com/leastprivilege/ASP.NET-WebApi-Security&gt;</description>
    </item>
</rdf:RDF>
