ASP.Net Application/Page Life Cycle



ASP.NET life cycle is divided into two categories

1. Application Life cycle
2. Page Life cycle.


Application Life Cycle 

1. User request a page.

2. Browser send user request to web server/IIS.

3. IIS check which ISAPI extension can process the request. For ASP.NET page request , it will be passed to ‘aspnet_isapi.dll’. depending on extension, IIS decides which DLL should be called.

4. ApplicationManager objects is created.

5. If the request is first request to the website, then application manager creates application domain to run the website. If not application domain is picked from application pool. Application domain helps to create isolation between two web application in same IIS server. So that failures of  one application domain does not affect to other application domain.



6. HostingEnvironment objects is created - application domain creates hosting environment.

  •      HttpRuntime object is created.
  •       ASP.NET objects(‘HttpContext’ , ‘HttpRequest’ and ‘HttpResponse’ ) are created.

7. ‘HttpApplication’ object is created to serve request.


8. ‘global.asax’  object is created if we have ‘global.asax’ in application.


Tag : ,

DocumentDB-NoSQL database

Microsoft Azure team announced a new NoSQL database named "DocumentDB" which is fully managed and scalable.
In generally we can write Trigger, Stored Procedure and User Defined Function (UDF) in JavaScript.

Introduction to Microsoft Azure DocumentDB
http://azure.microsoft.com/en-us/documentation/videos/introduction-to-azure-documentdb/

Tag : ,

Simple ASP.NET Web API 2 Sample


 Simple ASP.NET Web API 2 Sample


Steps:

1. Start Visual Studio and select "New Project".


2. Select ASP.NET Web Application under installed Templates.

3. Select Empty template in next dialog. Make sure to tick "Web API" checkbox under "Add folders and core reference"

4.  Add Model Class inside Models folder(Sample project I have added "Students")


  1.   public class Students
  2.     {
  3.         public int Id { get; set; }
  4.         public string Name { get; set; }
  5.       
  6.     }

5 Add a Controller, Right click controller folder and add "Web API 2 Controller - Empty"

6. Now modify controller to have data as you need, In sample I have added dummy Student array  and return methods(for all and by ID)

7. Now Just add a HTML page to test your code. Hurry up!!!.

  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.     <title></title>
  5. </head>
  6. <body>
  7.     <div>
  8.         <h2>All Students</h2>
  9.         <ul id="Students" />
  10.     </div>
  11.     <div>
  12.         <h2>Search by ID</h2>
  13.         <input type="text" id="StudentId" size="5" />
  14.         <input type="button" value="Search" onclick="find();" />
  15.         <p id="Student" />
  16.     </div>
  17.     <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
  18.     <script>
  19.     var uri = 'api/products';
  20.     $(document).ready(function () {
  21.         // Send an AJAX request
  22.         $.getJSON(uri)
  23.             .done(function (data) {
  24.                 // On success, 'data' contains a list of products.
  25.                 $.each(data, function (key, item) {
  26.                     // Add a list item for the product.
  27.                     $('<li>', { text: FormatItemData(item) }).appendTo($('#Students'));
  28.                 });
  29.             });
  30.     });
  31.     function FormatItemData(item) {
  32.         return item.Name;
  33.     }
  34.     function find() {
  35.         var id = $('#StudentId').val();
  36.         $.getJSON(uri + '/' + id)
  37.             .done(function (data) {
  38.                 $('#Student').text(FormatItemData(data));
  39.             })
  40.             .fail(function (jqXHR, textStatus, err) {
  41.                 $('#Student').text('Error: ' + err);
  42.             });
  43.     }
  44.     </script>
  45.         </body>
  46.         </html>
8. Download Sample code Here.

Sample OUTPUT.




Tag : ,

Database in recovery State.



While I was working on production database server , I noticed one of database is in recovery state and relevant web site is down.  Following command is used to change database recovery state in to normal state.

RESTORE DATABASE database_name WITH RECOVERY

You have to run above code in master database. More details can be found in below URL.


Tag : ,

- Copyright © AjithNet Tech blog - Skyblue - Powered by Blogger - Designed by Johanes Djogan -