Web Applications Using ASP - Net-Basics
Web Applications Using ASP - Net-Basics
Using ASP.NET
We will study mainly this area from the following resources:
1. Type the exact location and name of the page in the URL bar of the browser.
2. Save the page(s) on web server. It involves the following steps:
1. A web author writes a page composed of pure HTML, and saves it within an .htm file
on the server (computer).
2. Sometime later, a user types a page request into their browser, and the request is
passed from the browser to the web server
3. The web server locates the .html page and converts it to an HTML stream.
4. The web server sends the HTML stream back across the network to the browser.
5. The browser processes the HTML and displays the page.
They are quite limited without any dynamic features like displaying current time.
Also HTML offers no features for personalizing your web pages; each web page that
is served is the same for every user.
There's also no security with HTML, the code is there for everybody to view, and
there's nothing to stop you from copying somebody else's HTML code and using it in
your own web page.
Static pages might be very fast, as quick as copying a small file over a network, but
they are quite limited without any dynamic features.
A site that is reactive, like to display the current date and time.
A site which displays the values from an attached database file on the Internet like price of an
item,
A site to display a stock catalogue (web service),
Or you wanted to personalize your site to everyone who visited it, like administrator or user.
Client-Side Scripting:
In the client-side model, modules (or plug-ins) attached to the browser do all the work of creating
dynamic pages. The HTML code is typically sent to the browser along with a separate file containing
a set of instructions, which is referenced from within the HTML page. However, it is also quite
common to find these instructions intermingled with the HTML codes. So, in this model, our set of five
steps now becomes six:
1. A web author writes a set of instructions for creating HTML, and saves it within an
.html file. The author also writes a set of instructions in a different language (to
handle dynamic content). This might be contained within the .htm file, or within a
separate file.
2. Sometime later, a user types a page request into their browser, and the request is
passed from the browser to the web server. (When you type a web address like
www.wrox.com in your web browser and press Enter, the browser sends a
request to the web server at that address. This is done through HTTP, the
HyperText Transfer Protocol. HTTP is the protocol by which web browsers and
web servers communicate. When you send the address, you send a request to
the server. When the server is active and the request is valid, the server accepts
the request, processes it, and then sends the response back to the client
browser.
Because you are using the built-in Development Web Server, the server and the
client are really the same machine. However, in a real-world scenario, you’ll host
your web site on an external web server where it can be accessed by many
different clients.).
3. The web server locates the .html page, and may also have to locate a second file
that contains the instructions (written in any scripting language).
4. The web server sends both the newly created HTML stream and instructions
back across the network to the browser.
5. A module within the browser processes the instructions and returns it as HTML
within the .html page – only one page is returned, even if two were requested.
6. The HTML is then processed by the browser which displays the page.
Everything you see, click, and interact with on a website is the work of front-end web development.
Client-side frameworks and scripting languages like JavaScript and Angular JS have made
interactive websites possible. Here’s a look at how this technology works in the scheme of a website,
and some of the most popular scripts and frameworks you should know.
The client is anywhere your users are viewing your site: mobile devices, laptops, or desktop
computers.
Client-side scripting is always evolving—it’s growing simpler, quicker, and easier to use. As a result,
sites are faster, more efficient, and less work is left up to the server. Server-side scripting works
in the back end of a site, which the user doesn’t see. It creates a way for the site to access its
database, all the behind-the-scenes mechanics that organize and power a website. Client-side code,
however, handles what the user does see.
Benefits of client side scripting:
Execute quickly because they don't require a trip to the server.
Are reusable and obtainable from many free resources
Create dynamic forms.
Drawbacks of client side scripting:
Client-side technologies have fallen out of favor in recent times, as they take a long time
to download, especially if we have to download a second file with a separate set of
instructions. In some cases, we might have to download several files of separate
instructions.
A second drawback is that each browser interprets these instructions in different ways, so
we have no way of guaranteeing that if Internet Explorer understands them, whether
Netscape Navigator or Opera will.
Other major drawbacks are that it is a problem to write client-side code that uses server-
side resources such as databases, because it is interpreted at client-side.
Also all code for client-side scripting is available to everybody, which can be undesirable.
Latest technologies in Client side Scripting:
Now that you’ve got a broad view of what front-end technology is and does, here’s a look at some of
the most widely used scripting languages and front-end frameworks. Languages are almost always
used in the context of their frameworks, which make quick work of complicated code with libraries of
pre-packaged, shareable code, and lots of add-ons. Your developer, in addition to HTML, CSS and
Java Script may use one or a combination of these when building the front end of your site. These
are actually frameworks of Java Script.
AngularJS: An incredibly robust JavaScript framework for data-heavy sites
JQuery, jQuery Mobile: A fast, small, JS object library that streamlines how JavaScript behaves
across different browsers
Node.js: A server-side platform that uses JavaScript, and is changing the way real-time
applications can communicate with the server for faster response times and a more
seamless user experience. It works with another JavaScript framework, Express.js, to build
server-side Web applications.
Bootstrap: A mobile-first framework that uses HTML, CSS, and JavaScript to facilitate rapid
responsive app development
React, for user interface design
Express.js, Backbone.js, Ember.js, MeteorJS, and more
TypeScript: A compile-to-JavaScript language that is a superset of JavaScript, created by
Microsoft
AJAX (JavaScript + XML)—a technology that allows specific parts of a site to be updated without
a full-page refresh by asynchronously connecting to the database and pulling JSON– or XML-
based chunks of data.
VBScript & JScript are Microsoft’s front-end scripts that run on the ASP.NET framework. JScript
is Microsoft’s reverse-engineered version of JavaScript.
ActionScript, which creates animated interactive web applications for Adobe Flash Play
Java (as “applets”) snippets of back-end code that run independently with a run-time
environment in the browser
Tip:
It’s worth researching what browsers your primary audience is most likely to use, and what back-end
scripts and APIs you’re using, and then decide on a script based on a stack or compatibility.
Client-side scripting breakthrough:
An important breakthrough that changed the hard-and-fast rules for client side vs. server side? AJAX.
The old standard was that server-side processing and page post-backs were used when the browser
needed to interact with things on the server, like databases. AJAX, with its asynchronous calls to the
server, can pull the data instantly and efficiently, without requiring a post-back. Read more about how
it works in this AJAX Front-End Technology article.
Another major boost is jQuery, a fast, small, and feature-rich JavaScript library with an easy-to-use
API that works across a multitude of browsers. Like code libraries do, jQuery changed the way that
millions of people write JavaScript, simplifying a number of other client-side scripts like AJAX at the
same time.
Server-Side Scripting:
With the server-side model, the HTML source is sent to the web server with an intermingled set of
instructions. Again this set of instructions will be used to generate HTML for the page at the time
the user requests the page. Once again, the page is generated dynamically upon request. Our set of
five steps once more becomes six, however, with the subtle twist regarding where the processing of
instructions is done:
1. A web author writes a set of instructions for creating HTML (including the dynamic
part of the code), and saves these instructions within a file.
2. Sometime later, a user types a page request into their browser, and the request is
passed from the browser to the web server
3. The web server locates the file of instructions
4. The web server follows the instructions in order to create a stream of HTML
5. The web server sends the newly created HTML stream back across the network to
the browser.
Are the support, skills, and knowledge required to use them readily available?
History of ASP.NET:
ActiveX Controls:
An ActiveX control is a self-contained program (or component), written in a language such as C++ or
Visual BASIC. When added to a web page, it provides a specific piece of client-side functionality,
such as:
a bar chart,
timer,
client authentication, or
database access.
ActiveX controls are added to HTML pages via the <object> tag, which is now part of the HTML
standard. Despite being compatible with the HTML standard, they are not supported on any browser
without an ActiveX plug-in. Without this, they will only function on Internet Explorer. Also, unlike
VBScript, ActiveX is able to manipulate items on the user's machine such as the files or Windows
registry. For this reason it is very often considered a security risk and is not even allowed through
firewalls. Consequently, ActiveX controls still can't really be considered either a common or a cross-
platform way of making your pages dynamic and are falling out of use.
ASP:
Active Server Pages (ASP) is now dubbed (named formally) "Classic ASP" and if you see this term
in the book, we will be using it to describe any ASP that isn't ASP.NET.
ASP commonly relied on either of the JavaScript or VBScript scripting languages (although it was
also possible to use any scripting language installed on Windows, such as PerlScript) to create
dynamic web pages. ASP is a module (the asp.dll file) that you attach to your web server, and it then
processes the JavaScript/VB Script on the web server, and turns it into HTML, before sending it into
the server, rather than doing it on the browser. ASP lets us use practically any of the functionalities
provided by Windows, such as database access, e-mailing, graphics, networking, and system
functions, and all from within a typical ASP page.
ASP's shortcomings:
It is very, very slow performance wise.
It is also restricted to using only scripting languages. It can't do all the things that a fully-
fledged programming language can. Secondly, the scripting languages, being like
"junior" versions of full programming languages, took a lot of shortcuts to make the
language smaller. Some of these shortcuts make their programs more complicated
than is otherwise necessary.
As we're going to see, ASP.NET rectifies a lot of this by making code more structured, easier to
understand, and shorter.
ASP.NET:
ASP.NET also relies on a module attached to the web server. However, the ASP.NET module
(which is a physical file called aspnet_isapi .dll) doesn't do all of the work itself; it passes some on to
the .NET Framework to do the processing for it.
How does ASP.NET differ from ASP?
We add ASP code to our pages in the same way as we do client-side script, and this leads to
problems such as messy coding and restricted functionality. ASP.NET has no such problems.
First off ASP.NET allows you to use a far greater selection of full programming languages and
also allows you to utilize to the full the rich potential of the .NET Framework. It helps you create
faster, more reliable dynamic web pages with any of the programming languages supported by
the .NET Framework. Typical languages supported natively are VB.NET, C# and a new version of
JavaScript called JScript.NET. On top of this it is expected that third party developers will create
versions of Perl, Python, and many others to work in ASP.NET. We've chosen VB.NET as its
arguably the simplest for beginners, and it can do pretty much anything that the other languages we
mentioned can as well. Lastly, and most importantly we've chosen VB.NET as it comes free with
ASP.NET – so when you install ASP.NET you get VB.NET as well.
A clean separation between presentation and code. With classic ASP, your programming logic was
often scattered throughout the HTML of the page, making it hard to make changes to the page later.
ASP.NET and VB.NET (or C#)
At this stage, you might be thinking, "Hang on, I've got to figure out VB.NET, then I've got to get a
handle on ASP.NET – that sounds like an awful lot to learn." Don't worry; you won't be learning two
languages. ASP.NET, as we said right from the beginning, is not a language – it is a technology. This
technology is accessible, via a programming language. What we're going to be doing is teaching you
ASP.NET features as we teach you VB.NET. So in other words, you will be creating your web pages
using VB.NET and using ASP.NET to drive it. However, before you rush out and get a VB.NET book
instead, we will be approaching the language from the angle of creating dynamic web pages only.
In summation, ASP .NET is a server-side technology that lets us use fully-fledged programming
languages to create your web pages.
An introduction to ASP.NET:
ASP.NET is a framework (Set of libraries. It’s a part of .net framework) that supports the building of
robust and performant web applications.
Think of it as the structural support for a car. You can add a couple of different body designs on
top of this structure: ASP.NET Web Forms and ASP.NET MVC. These two approaches both rest on
ASP.NET.
The current versions, Visual Studio 2010 (often pronounced as “twenty-ten”) and ASP.NET 4, build
on top of the successful Visual Studio 2008 and ASP.NET 3.5 releases, leaving many of the beloved
features in place, while adding new features and tools in other areas.
Now see in Beginning ASP.net 4.5.1 (wrox’s book) from p. xxxiii. And follow this way to read:
1. Keep reading and highlighting the most important matters and also keep performing any
practical work along with.
2. After one chapter is finished, keep revising the highlighted text by copying the highlighted
text in the word file and arranging and remembering the text from this word file.
3. After that attempt exercises.