MenuBar

Tuesday 22 July 2014

Difference between asp.net Website and Asp.net Web Application

This is the most mystifying concept in asp.net web development because most novice developers think that these both are same. Because of same steps need to take to create a project or a website. Website and web application both are different and both have advantage and disadvantage. But choosing between them is depends on requirement.
Now see the differences step by step:-

ASP.NET Web Application (Web project):


1.    In web application ,all Business logic (classes),configuration files, resources are placed in the same root directory and compiled into dll.

2.    In visual studio, it is old and default methodology for creation of an application, all application need to have a project file just like windows application project, so web project also has a project file called csproj for C# or vbproj for Vb.net.

3.  Web application creates on project for whole application based on one language you choose for example :- if you choose c# as your application language  then whole project will depend on that language and you need to add all pages in c# language. You can’t add pages in vb language. C# language project created in .csproj, and vb language project in .vbproj extension.

4.   Web project need to pre-compiled before deployment. If any change takes place in any page then again need to re-compile whole application.

5. Migration from old version to new is easy in web application. For example- web application project created in visual studio 2005 can be easily migrate in visual studio 2008.

6. Web application should be created when you have a really huge website, large number of team member.

7.    Steps to create Web application

Open visual studio àgo to file ànew project


Creating web application


ASP.NET Website (projectless website) 


1.    In WebSite, special folders are available for placing different types of files like classes can be stored in App_Code directory, which is compiled automatically and can be accessed throughout the pages in web site.

2. On the other hand, website pages can be created in  multi-programming language          like we can add a page using C# language and Vb on another page in same website.

3. Web site creation is new methodology added in visual studio, it doesn’t need to have a project file like .csproj or .vbproj, any file can be created and deployed easily. 

4. Web site doesn’t need to pre-compiled before deployment. Any change can take place in .aspx and code- behind and just need to replace old to new page by simply uploading, not need to worry about compilation. It dynamically compiled and maintained at runtime.

5.  Migration from old version to new is difficult in web site because of projectless.

6. Web site should be chosen when you have average website, small number of team member.

7.    Steps to create Web application

Open visual studio àgo to file ànew website

Creating web site




Video Reference 

Wednesday 16 July 2014

ASP.NET Application folder (also called special folder) for maintaining security, accessibility, durability and robustness in ASP.NET Websites

In a general website there are collection of files, resources posted on website’s root folder that used by web pages globally on the same website like .aspx files, .jpg file, .txt files, .js scipt files, .css files etc. these resources need to placed in same website folder so it can be used by Web Pages.

Sometimes it can be vulnerable to keep these resources in website folder because of internet junkies that always keep their eyes on vulnerable sites to hack those resources.
Thanks to ASP.NET , it provide application folder to place resources, files In a standard manner that maintain by .NET run-time.

ASP.NET 3.5 supports eight types of special folders and each folder has their own advantage. I will explain these eight in details.

  1. App_Browsers
  2. Bin
  3. App_Code
  4. App_Data
  5. App_GlobalResources
  6. App_LocalResources
  7. App_WebReferences
  8. App_Themes

By default these special folder are not available in your empty website , but you can add easily when you need in few steps

Steps :
  1. Create a website in visual studio by clicking on Menu  file à New website .
  2. On solution explorer right click on root folder à Add Asp.Net Folder àchoose from Eight ASP.NET folder you want



In a website you can add each of these folders only once. The folder that you will add once will remove from add option automatically.
These folder maintains access security. No one can access files of these folder directly through the url, if someone really does so server gives forbidden  message. 

Let’s dig into these special folders

App_Code Folder :

In App_Code Folder we can place class files like .cs or .vb , text and xml files. It will compiled automatically and can be access throughout the web application, means we can access directly on all the pages that is created on current website. In three layered architecture App_Code plays very important role.  To add App_Code folder àOn solution explorer right click on root folder à Add Asp.Net Folder àApp_Code  and its done.
After that to add new or existing files on App_Code right click on App_Code folder à Add New Item à choose file  its done.



App_Browsers :

App_Browsers is used to access browser information and capabilities.This folder contains browser information files like .browser.
Bin Folder:
In this folder we can placed executable files or assembly  files that can be reference throughout the web application .



App_Data Folder :

We can place database files in this folder like .mbf, .mdb,Xml etc. by doing this database file can be accessed anywhere in our web application. We can add .mbf, .mdb,Xml files to the App_Data folder directly by selecting Add New Item.

App_GlobalResources :

We can store resources that we need to access in any page or any code. ASP.NET uses resource files to make supporting multiple languages simpler. We can store single resource file that need to use in multiple pages globally. You can add a global resource file by right clicking on the App_GlobalResource  folder and clicking on Add Items.

App_LocalResources :

The App_LocalResource  folder contain local resource files . we can place  resources file on subfolder of website , in App_LocalResources we can store resources that need to be used by local webpage. There can be multiple App_LocalResources folder in a website but in subfolder that locally access it.You might have local resources for every page in your website, you might have App_LocalResource subfolders in every folder.

App_WebReferences :

App_WebReference  folder contain references to any web services. We can easily add new web reference to our web application by right clicking on App_WebReference  folder à add web reference.

App_Themes :

We can store page styling files like .css, .skin file to this folder. We can create theme style for our web page. When we add an App_Theme folder, a subfolder with name Theme1 will be automatically created.  We can rename it and then add .css to it. These styles can be applied to ASP.NET control directly. We can as many themes as we want but folder name should be unique. 

Tuesday 15 July 2014

Asp.net page life cycle (the internal of request and response process in asp.net)

As you all know that request and response process is very common, but for any non developer or user’s point of view it’s just a process of calling or requesting for a page through typing the name of page or clicking on a link of page, the requested page will gets found and will display on user’s browser as simple as that.
But the internal process of request and response is far complicated then it looks like. As a web developer it is very important to understand the internal working process of request and response, what happened when user send request to server, how web server get the request and then response back to user.
So in this post I will try to explain the internal process of page request and response and try to clear your concept on asp.net page life cycle.

In asp.net the process of a request for asp.net page from user’s browser, then request acquired by web server and then server sends response back to the user’s browser. In between these processes IIS (Internet Information Services) performs and maintains collection of stuff.

Small Intro of IIS (Internet Information Services) 

IIS is a web server software, which waits for browser requests and serves the appropriate pages.
In a simple word, when you want your website to be publically accessible through the internet, you need to publish it on IIS web server (in case of ASP.NET).

A variety of colors of IIS

• Windows XP Professional comes with IIS 5.1. (Previous version or other editions of Windows XP don’t include)
• Windows Server 2003 comes with IIS 6.
• Windows Vista and Windows Server 2008 come with IIS 7.

IIS request and response phenomenon 

Initial handling is actually performed by the kernel-mode HTTP driver http.sys.When user sends a request to IIS,request goes through ISAPI filter . ISAPI.dll checks requested file extension and performs further action accordingly in the case of .aspx page then it sends to ASPNET_ISAPI.dll extension to process request. As explained in picture below:



IIS request handling

IIS checks whether it is the first request for the website or not then a class called ‘ApplicationManager’ creates an application domain where the website can run. The application domain is responsible for maintain isolation between two or multiple  web sites hosted on the same IIS web server. After that http runtime object created to create hosting environment for all aspx page. Once the hosting environment is created, the compulsory core  ASP.NET core objects (HttpContext , HttpRequest, HttpResponse). After that main object is created which is responsible to serve the .aspx page is called HttpApplication. In case if website has global.asax file available then the object of global.aspx class is created.
HttpApplication object has the command of all core object of asp.net that created earlier. Now HttpApplication of object process the request by calling HttpModules, HttpHandlers and Page events.

These three objects invokes different events that can be  used by developer to insert  logic within that as required.


HttpHandler :

HttpHandler is an extension based processor that means it checks the extension of requested file and then calls appropriate handler. To get more clear see the image below :




HttpHandler

HttpModule :

HttpModule is an event based processor, that means we can insert code in ASP.NET pipeline events. ASP.NET pipeline events are listed in the order that they occur:





Description of all above Event below :


BeginRequest
This event indicates that a new request occurred  and guarantees to be raised on each page request.

AuthenticateRequest
This event indicates that ASP.NET runtime is ready to authenticate the user and any authentication code can be injected here as required.

AuthorizeRequest
This event indicates that ASP.NET runtime is ready to authorize the user and Any authorization code can be injected here as required.

ResolveRequestCache
In this event, ASP.NET runtime take decision whether the page can be served from the cache rather than loading the original for increase the performance. Any caching specific code can be injected here.

AcquireRequestState
This event indicates that ASP.NET runtime is ready to acquire session variables.

PreRequestHandlerExecute
This event is indicates that to handling control to the HttpHandler can be done and required code can be injected.           

ProcessRequest
In the case of HttpHandler defined in page ,Httphandler logic is can be written logic which needs to be executed as per page extensions.

Page  Init
This event raised just before page load and code like Creation of controls dynamically, Any initialization  etc.

Load
This Event guarantees that ASP.NET controls are fully Loaded and you write code logic as required.

Validate
If you have any validation controls  on your page, you can check whether validated or not and write code as required.


Render
When request processed by the server then it need to be send back to user’s browser rendered as simple html code, so before rendering you can insert final code to change something you want.

Unload
This event is called when Page object is going to unloaded and released all created objects from the memory.

PostRequestHandlerExecute
This event occurs after the handlers are executed successfully any code logic can be injected here.

ReleaserequestState
In this event all saved state for page gets released you can save state
variables like session variables if you need.

UpdateRequestCache
In this event you can update your cache if you need.

EndRequest
The End of the Request.
I hope so that this post help you to understand the lifecycle of ASP.NET Page.



Video Reference 



Monday 7 July 2014

Differences between ASP and ASP.NET (Most often but confusing question for novice developers)

Most novice developers think that asp and asp.net is same, but guys there are a lot of differences between ASP and ASP.NET. Asp is an old day style of web development in which a bunch of ASP code were used to embed in between html codes. On the other hand, ASP.NET has giant .Net Library support and compiled language support like C#.NET,Visual Basic .NET.
Here are some more differences between ASP and ASP.NET below

  1. ASP is Interpreted language based on scripting languages like Jscript or VBScript.
  2. ASP has Mixed HTML and coding logic in a single file.
  3. Limited development and debugging tools available.
  4. Some degree of OOPS support.
  5. It doesn’t support xml.
  6. Insufficient session and application state management.
  7. ASP session state relies on cookies.
  8. ASP has no inbuilt facility for Validation of controls.
  9. Extension of asp web page is *.asp.


  1. ASP .NET is fully Object Oriented Programming.
  2. ASP.Net has .NET library support and has compiler and compiled language support hence more secure then ASP.
  3. ASP.NET has xml support for easy data exchange.
  4. Separate code and design logic possible.
  5. It supports to create Multilanguage pages like one page in c# language or other page in VB.NET as well in same website.
  6. Variety of tools available includes the Visual studio.Net.
  7. ASP has supports inbuilt Rich Validation set of controls like RequiredFieldValidation, CompareValidator, RangeValidator, RegularExpressionValidator, CustomValidator Control.
  8. Complete session and application state management.
  9. Full XML Support for easy data exchange.
  10. ASP.NET session state relies on cookies as well as server.
  11. Extension of ASP.NET pages is *.aspx


Video Reference 



Saturday 5 July 2014

Fundamentals of ASP.NET and stuffs that need to know before start with ASP.NET web development

Okay friends to get started you have to have some very basic idea and awareness about generic terms, rules and ‘why n how’ of everything that is used in asp.net web development.  Here I am explaining about some of them below that you need to know:

Flavors of ASP.NET

With a new flavor of ASP.NET 4 Microsoft again refining and enhancing ASP.NET. It has old functionality as well as News Dynamic features that give a pace to developers and to make their programming more productive.

       ASP.NET 1.0 :- This version created the core ASP.NET platform and introduced a collection of features.

       ASP.NET 1.1 :- This version only refined with bug fixes that increased the performance.

       ASP.NET 2.0 :- This version came with huge set of new features on top of the ASP.NET previous version.

       ASP.NET 3.0 :- This version was just for filling gaps of technologies, it doesn’t touch the core of asp.net but added new framework including Windows Presentation Foundation (WPF), Windows Workflow Foundation (WWF) and Windows Communication Foundation (WCF).

       ASP.NET 3.5 :- This version kept the same basic engine as ASP.NET 2.0, but adds a few add-ons. The most significant enhancement is the ASP.NET AJAX toolkit, which gives web developers better tools for creating highly responsive web pages that imitate the desktop applications (such as drag-and-drop and auto complete, Modelpopup etc). Also respect to Database it added LINQ that gives a platform to play with database queries more concisely with Architectural support of MVC.

       ASP.NET 4.0 :- This version added Dynamic data, enhancement of MVC and much more on top of ASP.NET 3.5.

Request and Response

HTTP Request :- A user sends a path of a file also called URL(Uniform Resource Locator) like (http://TechToTrick.com/ Welcome.aspx ) that is store in somewhere on the web server on the internet via browser (User Agent) using Get Method, is called  HTTP Request.
HTTP Response :- On the server side as name suggested, it receives request and then try to resolve the address and searches for that requested file on the server if requested file found then it returns that file to the user ,this process called HTTP Response. See picture below


Request and Response
IIS (Internet Information Server) :- Internet Information Server is one of the most powerful web servers Powered by Microsoft that is used to host and run  ASP.NET web applications. IIS has its own ASP.NET Process to handle ASP.NET requests.See picture below


IIS (Internet Information Server)

Thursday 26 June 2014

A Complete Asp.net tutorial to become novice to professional by Sam



Ok folk I am Sam and I am converting my blog techtotrick(t3) to a new level of expertise and going more professional.

I am gonna  start a new tutorial on web development , this tutorial is for those  who are very interested in web development and want to make their career on it. In web development there are number of scripts, computer languages and other type of tools are used. In this tutorial I will focus on a Server Side scripting language called ‘Microsoft Asp.net’, as it mention it a component of .NET that gives you a place to create dynamic pages. This tutorial will help those students who are novice in asp.net but wants to be veteran. In this tutorial I will explain every bit of asp.net with a small real time example program in c#. And you can also find related videos of Asp.net programming sample examples on my youtube channel very soon.



Prerequisites to start this tutorial


1.      Should have basic  knowledge of html

2.      Should have knowledge of .NET framework

3.      Should have knowledge of Visual Studio IDE

4.      Should have knowledge of SQL(Tables,Procedure,Triggers)

5.      Should have knowledge of web browser protocols(HTTP,FTP,SMTP etc)

So all check? Now you all set to start. To start see my next post.