Monday, 13 June 2016

Http Errors

Types of  HTTP Errors

Sometimes when you try to visit web page, you’re met with an HTTP error message. It’s a message from the web server that something went wrong. In some cases it could be a mistake you made, but often it’s the site’s fault.
Each type of error has an HTTP error code dedicated to it.

Lets have a look on types of Errors and Error codes.
Http-Hyper Text Transfer Protocol has a list of response status codes.
It was categorized into five classes of response.

  • 1xx Informational
  • 2xx Success
  • 3xx Redirection
  • 4xx Client Error
  • 5xx server error
 1xx Informational                                                                                                                      

Message
Description
100 Continue
The server has received the request headers, and client should proceed to send the request body.

101 Switching Protocols
The requester has asked the server to switch protocols

103 Checkpoint
Used in the resemble requests proposal to resume aborted PUT or POST requests.


2xx Success

Message
Description
200 OK
The request is OK
201 Created
The request has been fulfilled, and a new resource is created 
202 Accepted
The request has been accepted for processing, but the processing has not been completed

203 Non-Authoritative Information
The request has been successfully processed, but is returning information that may be from another source

204 No Content
The request has been successfully processed, but is not returning any content

205 Reset content
The request has been successfully processed, but is not returning any content, and requires that the requester reset the document view

206 Partial content
The server is delivering only part of the resource due to a range header sent by the client


3xx Redirection

Message
Description
300 Multiple choices
A link list. The user can select a link and go to that location. Maximum five addresses  

301 Moved Permanently
The requested page has moved to a new URL 
302 Found
The requested page has moved temporarily to a new URL 

303 See other
The requested page can be found under a different URL

304 Mot modified
Indicates the requested page has not been modified since last requested

306 Switch proxy
No longer used

307 Temorary redirect
The requested page has moved temporarily to a new URL
308 Resume Incomplete
Used in the resemble requests proposal to resume aborted PUT or POST requests.


4xx: Client Error

Message
Description
400 Bad request
The request cannot be fulfilled due to bad syntax

401 Unauthorized
The request was a legal request, but the server is refusing to respond to it. For use when authentication is possible but has failed or not yet been provided

402 Forbidden
Reserved for future use.
403 Forbidden
The request was a legal request, but the server is refusing to respond to it.
404 Not found
The request page could not be found but may be available again in the future.

407 Proxy Authentication Required
The client must first authenticate itself with the proxy
408 Request Timeout

The server timed out waiting for the request.
409 Conflict
The request could not be completed because of a conflict in the request

5xx Server Error

Message
Description
500 Internal Server error
A generic error message, given when no more specific message is suitable

502 Bad Gateway
The server was  acting as a gateway or proxy and receive an invalid response from the upstream server.

503 Service Unavailable
The server is currently unavailable (overloaded or down)
504 Gateway Timeout
The server was acting as a gateway or proxy and did not receive a timely response from the upstream server





Wednesday, 1 June 2016

Cache Management & Security

What is Caching and what are the benefits of using it?
Caching is an area of a computer’s memory devoted to temporarily storing recently used information. 
    cache memory diagram
  • The content, which includes HTML pages, images, files and Web objects, is stored on the local hard drive in order to make it faster for the user to access it, which helps improve the efficiency of the computer and its overall performance.
  • when a user returns to a Web page they have recently accessed, the browser can pull those files from the cache instead of the original server because it has stored the user’s activity.
Advantages

The advantages of web caching via proxy servers include: 
  • faster access to valid cached resources
  • saving on costly use of bandwidth
  • imposing controls on access to dubious material
  • collecting useful statistics on web access
  • providing cached resources even when origin server is down
Disadvantages
Disadvantages of web caching include 
  • slower performance if the resource isn't found in the cache
  • being given a stale copy of a resource when an uptodate copy is needed
  • resources sometimes getting mangled/lost on route
  • sharing an access point to the web increasing risks to service
  • proxy server access logs invading the privacy of users
  • proxy intermediary confusing logging and access control by subscription services
                                          ------------------------**-------------------------
Cache Management in ASP.NET?
ASP.NET provided support for Cache Management in almost all versions. In .NET Framework 3.5 and older, the support for caching was provided through classes available in System.Web.Caching. But this support was limited to System.Web meaning for ASP.NET Web Applications only. Now, with .NET Framework 4.0 and later, this support is enhance to non-Web Applications also by providing APIs inSystem.Runtime.Caching.
ASP.NET supports three types of Caching:
  • Page Output Caching
  • Partial Page Caching
  • Data Caching
                       ------------------------**-------------------------
How to use Page Output Cache in ASP.NET?
The output of a complete web page is stored in a cache. So, when that web page is accessed again, it will be loaded from cache instead of fetching page data again from data source.
                                          ------------------------**-------------------------
How to use Page Fragment or Partial Page Cache in ASP.NET?
For Partial Page Cache (also known as Page Fragment Cache), a part or fragment of a web page is stored in Cache as opposed to complete page caching for Page Output Cache. For example, caching a user control on a web page that displays product categories using Page Fragment Cache.
                                          ------------------------**-------------------------
How to use Data Cache in ASP.NET?
In some scenarios, we may store frequently used objects into cache using ASP.NET Cache API. So, later on, that object will be loaded from cache instead of instantiating object again and fetching data from original source for it.
                                          ------------------------**-------------------------
Authentication Vs Authorization?
Authentication and Authorization are two key security related concepts that are independent but normally go together.
Authentication is a process that verifies the identity of a user. On ther hand, Authorization is the process of assigning rights/privileges to already authenticated user.
                                          ------------------------**-------------------------
What are the available Authentication modes in ASP.NET?
There are four types of authentications in ASP.NET i.e.
  • Windows Authentication
  • Forms Authentication
  • Passport Authentication
  • Anonymous access
                                          ------------------------**-------------------------

What is Protected Configuration in ASP.NET?
While developing an ASP.NET application, we normally store a number of important sensitive information in our config files like encryption keys, connection strings etc. Application vulnerability increases if this sensitive information is stored as plane text. So Protected Configuration is an ASP.NET feature that enables to encrypt such sensitive information in configuration files.
                                          ------------------------**-------------------------