The requested URL
Understanding the URL-variables
|| - The request method (GET/POST/DELETE etc)
|| - The complete URL in string format
|| - Everything before the "?", one row per part.
|| - All request variables, both the variable name and value. These values are already URLDecoded.
|| - The previous url that triggered this request.
The Method representing the type of http-request that is done by the client. GET is most common, where the user want data based on an URL. Other methods are POST, DELETE, PUT and HEAD. In an application, the POST and DELETE functions are most common. With GET, POST and DELETE, you have the all the basics to create powerful CRUD (Create, Read, Update, Delete) API's. It is many ways to build applications like this, POST can be used for both Create and Update.
The full URL from the request including http:// or https:// and get parameters. Can be used for logging. If you want to handle different parts of the URL, you should look at @UrlParts and @UrlParams.
The different parts of the url represented as a table. You will find one row for each part of the url seperated by "/". http://www.angularjsmssql.com/api/data, will be divided into 5 parts. "http" as part 0, domain as part 2, "api" as part 3 and "data" as part 4.
To use the different variables, it could be a good thing to translate them to variables. It could be done like this:
DECLARE @Domain varchar(200)
SELECT @Domain=Value FROM @UrlParts where id = 2
This information is similar to UrlParts, but represent the parameters in the url, normally the parts after the first "?". For example http://www.angularjsmssql.com/api/login?username=john&password=pw123, this will give two rows for the @UrlParts, one row with "username" and "john", and one row with "password" and "pw123".
To translate the different variables to a seperate variable, it can be done like this:
DECLARE @UserName nvarchar(200)
SELECT @UserName=Value FROM @UrlParams WHERE Param = 'UserName'
This will show the url that initiated the request. In an AngularJS application, this will normally be the URL that asked for the information. If you use this handler to build complete web-portals, this will be the previous URL that the user was coming from.
Last updated: 15 oct 2015