What is Web Application? Understand ASP.NET Basics.
In this article we will learn about what is web application? What is ASP.NET ? and few basic concepts of ASP.NET. Let us start –
What is web Application?
A web application is application software that is installed on server computer and runs on a web server, unlike computer-based software programs that are run locally on the operating system of the device. Web applications are accessed by the user through a web browser with an active network connection/ internet.
A web application, application software designed, developed , consumed usng web (internet based /web technologies)
Web Apps using Microsoft.NET
Microsoft.NET is well know, object oriented and stable application development platform used by many companies to develop various types of applications.
Microsoft.Net Provides you following options to develop the web applications –
Silverlight is a outdated product and it’s support is already ended by Microsoft so we will not discuss this product in this article, we will focus on the ASP.NET.
What is ASP.NET?
ASP.NET is an open-source, server-side web-application framework designed for web development used to develop dynamic web applications. It was designed developed by Microsoft to allow programmers/developers to build dynamic web sites (web applications) and web services (API’s). It is built on top of .Net Framework so consumes all the features of .Net Framework.
ASP.Net Technology Stack
If you look at following diagram you can easily understand the asp.net technology stack –
Using ASP.NET you can develop the Web Apps as well as Web Services. To develop the web applications using ASP.NET MVC we have following three options –
ASP.NET WebForms :-
Developer friendly technology released with initial version of .NET Framework which allow you to develop event driven web applications with features like drag and drop, built in controls, master pages etc. It provides you rapid application development. If you look at the todays world you find so many new concepts, technologies and infrastructures evolved in last 8 years due to which we find the Webform is limited to develop the web applications.
The major limitation is as load the grows in web form application it becomes slow and we can not afford this because their is tremendous growth in internet users from last 6/8 years.
Next major thing happend is cloud and web form applications struggles adjusting with cloud infrastructure.
keeping these facts in mind microsoft came with ASP.NET MVC as new technology to develop the modern web applications.
Web Technology built on top of ASP.NET which will help you to develop the cloud ready, modern web applications using MVC Design Pattern.
In ASP.NET Mvc we do not have drag and drop, built in controls, event driven programming it support the basic model of web called Request/Response.
ASP.NET Mvc follows MVC desing pattern , it has request and response model , light weight UI which makes it very fast. It can carry 60% more load as compare to webform on the same infrastructure.
Through out this series of arcitles we will try to understand more about ASP.NET MVC.
ASP.NET Web Pages:-
One of the web technology released with 3.5+ sp1 version of .Net Framework built on top of ASP.NET. This web technology this will you develop the dynamic web pages where we combine HTMl,CSS + Server code(C#/VB) in one page to develop the dynamic web pages. It is not suitable for large web applications, so we are not going to discuss this.
To Develop the service ASP.NET Provides you following two technologies –
ASP.NET XML Web Services :-
XML Web services is released with from .NET Framework 2.0 which allow you to develop the webservices. Here we develop the web services using HTTP/HTTPS, XML + SOAP. XML Web services are very delicate and are not suitable for complex or large business logic. It can be hosted web server and consumed using web browser so it needs web infra without web can not use it.
Is new options released by Microsoft in .NET 4.5 which help us to design develop Http Based Services. Web APIS’ are self hosted can communicate XML, JSON, ASCII etc. It also has various features like –
> Content Negotiation
> Self Hosted
> Media Formatters
> Token Based Security
ASP.NET Common Concepts/ Basic Concept:
In this section we will try to understand few basic concepts of ASP.NET.
- is of type HttpRequest
- request object will be get created in every web application for every user request will be deleted as soon as you generate the response.
- hold all data/information (explicit /implicit data) that comes with request.
Query String Collection: -this is built in collection, it holds explicit data if user makes request with http get method.
Forms Collection: -this is built in collection, it holds explicit data if user makes reqeust with http post method.
Browser: – browser is also a collection used to the information of browser that comes with user request.
Cookies: – is also a collection from request object which will hold all the cookies comes with request.
- life cycle of request object is only for that request, as soon as response is generated it will be deleted.
- Of type Http Response
- encapsulate response generated by web application and send it to web browser.
- In response object we have lot of things out of that we will learn two methods –
Redirect(url): – it will divert the uer to specified url.
SetCookie(HttpCookie): – it will write that cookies in web browser.
-if is of type HttpCookie.
-cookie is small data/information that any web application can store in web browser.
-generally cookies are used to store user preferences, search keyword
-we will not store Sercure data in cookies like passwords,otp or pins since cookies are stored in client brower in Plain ASCII format.
-client can block the cookies if client want to block them.
-To write a cookie in browser we use response.
-with every request web brower will send the cookides to the web server implicitly.
Their are two typws of cookies –
1.Persistent Cookie :- expiry date and time, it will stored in browser till that expiry date and time.
2.Non Persistent Cookies: – no expiry date and time so those will be deleted as soon as you close browser.
Session Object: (HttpSession)
Session and Application are the state maintenance mechanisms in ASP.NET. It will help you to maintain state in web application.
Since http is stateless protocol, it treats every request as new request. So we to identify the user and to maintain the state of requests we need to use session and application.
This object will be get created on web server when user makes a first request and will be their in web server memory until user do not delete it.
It will be get created individually/separately for every user.
Every session will identified by a unique id called session id and this session id will be exchanged between client and server with every request in the form cookie using which web server can identify that user and process the request as per that user.
Sessions are used to store user specific data or information.
Session allow you to create variables and those variables are basically called session variables and can be created as follows –
Session provides you few methods –
Clear(): – method used to remove every thing from session.
Abandon(): – used to delete session
TimeOut :- session timeout, is time period after which session will be deleted automatically if user do not make any request within that time period.
default session timeout in IIS web server is 20 minutes
Application Object: – (HttpApplication)
Application object will be get created in web server memory once (only one time) when you start the application and will be shared between all the users of the application.
we can use the application object to maintain common state or data that will be shared between multiple users.
you can create a variables in application object using –
It will be get deleted when you stop application.
web.config file in ASP.NET
What ever web application that you create using ASP.NET weather it is webform, mvc or web pages application all these applications will have a one file called web.config file. Web.config is xml file used to define global/common configuration settings those can be accessed through out application in the form of xml.
XML (Xtensible Markup language):-
It is tag based language / technology just like html.
XML is used to communicate /share data across applications or between multiple applications.
It contains user defined tags
It is case sensitive
All xml documents are rooted it means every xml document start with root tag and all tags will be nested in root tag.
<? xml verision="1.0" ?> <Products> <Product> <ProductID>1</ProductID> <ProductName>Mouse</ProductName> <Price>450></Price> </Product> <Product> <ProductID>1</ProductID> <ProductName>Mouse</ProductName> <Price>450></Price> </ProductID> </Products
Web.config file contains built in tags which will help you to define common settings or values like connection strings, support email ids etc.
One ASP.NET Application can have multiple web.config.
Global.asax (Global Application Class)
Every asp.net application can have only one global.asax, it contains global application class. Global application provides you some built in events, those events can be used to develop the web application.
event will fired only once through out the life cycle of your web application when start the web application.
Application End: –
event will be fired when you stop the web application, fired only once.
event will be executed every time when a new session get started.
this even will be get fired again and again.
event will be fired when session get terminate/delete.
this will be again get fired every time when you delete the session.
Application Error:- event will be get fired only when their is some error in a application.