PLASMA UNIVERSITY
DOTNET ( ASP)
CHAPTER1. Getting Started with ASP.net 4
Lecturer: Ahmed Omar Osman
Getting Started with ASP.net 4
IN THIS CHAPTER, WE WILL COVER
WHAT ASP.NET IS
THE .NET FRAMEWORK.
COMMON LANGUAGE RUNTIME
INTERMEDIATE LANGUAGE
CLASS LIBRARIES
VISUAL WEB DEVELOPER
TAKINGA QUICK TOUR OF VISUAL WEB
DEVELOPER
CREATING A SIMPLE ASP.NET PAGE AND
VIEWING IT THROUGH A WEB BROWSER.
Introduction
ASP stands for Active Server Pages
ASP is a development framework for building
web pages.
ASP.NET is an exciting web programming
technology pioneered by Microsoft that allows
developers to create dynamic web pages.
Dynamic web pages are pages whose
content is dynamically regenerated each time
the web page is requested.
Versions of an ASP.NET
ASP.NET is a robust and mature technology. ASP.NET version
1.0 was released in January 2002 and quickly became the web
programming technology of choice for many. In November
2005, Microsoft released the much-anticipated version 2.0.
Two years later, in November 2007, Microsoft released
ASP.NET version 3.5. in 2010 version 4.0 in 2012 version 4.5
used And ASP.NET 4.5.1 was used with VS 2013 version.
The .NET Framework
The .NET Framework is an environment for designing,
developing, deploying, and running XML Web services, Web
applications, NT services, and Windows applications.
The .NET Framework is a rich platform for creating
Windows-based applications and is the underlying technology
used to create ASP.NET websites.
The .NET Framework collects all the technologies needed for
building Windows desktop applications, web applications,
web services, and so on, into a single package, and makes
them available to more than 40 programming languages.
The .NET Framework
All applications developed under the .NET
Framework, including ASP.NET applications,
have certain key features that ensure
compatibility, security, and stability
The .NET Framework is separated into two parts:
the common language runtime and the class
libraries .
common language runtime
The Common Language Runtime (CLR) is an environment
that manages the execution of code. In other words, it runs
and maintains any code that you write.
Traditionally, when you create an application, you write
code in a programming language, compile it into a format
that the computer can understand (1’s and 0’s), and then
execute it.
How about if you use different types of computers that
speak different languages? Recompilation of every new
computer’s language.
common language runtime
With the .NET Framework and CLR , instead of compiling it into
something the computer understands, you compile it into a language
called the Microsoft Intermediate Language (MSIL).
ASP.NET pages are compiled into MSIL as well. When you compile to
MSIL, your application produces something called metadata.
This information about your application tells what the application can do.
when you want to run your program, the Common Language Runtime
takes over and compiles the code once more into the computer’s native
language through the class loader Just-in-time (JIT) compilers compile
the intermediary language (MSIL) into native code,
common language runtime
common language runtime
Intermediate Language
All the .NET languages are compiled into another lower-level
language before the code is executed.
This lower-level language is the Common Intermediate Language
(CIL, or just IL).
The CLR, the engine of .NET, uses only IL code, because all .NET
languages are designed based on IL.
The .NET Framework formalizes this compatibility with something
called the Common Language Specification (CLS).
the CLS is a contract that, if respected, guarantees that a
component written in one .NET language can be used in all the
others.
Intermediate Language
One part of the CLS is the common type
system (CTS), which defines the rules for
data types such as strings, numbers, and
arrays that are shared in all .NET
languages.
The CLS also defines object-oriented
ingredients such as classes, methods,
events
Language compilation
in .NET
Language compilation
in .NET
Every EXE or DLL file that you build with a .NET
language contains IL code.
The CLR runs only IL code, which means it has no
idea which .NET language you originally used.
CLR actually performs another compilation step—
it takes the IL code and transforms it to native
machine language code that’s appropriate for
the current platform.
T hi s step occurs when the application is
launched, just before the code is actually
executed.
The just-in-time (jit) compiler
The just-in-time (JIT) compiler is the component
that converts the intermediate machine-
independent -Microsoft Intermediate Language
(MSIL)code - to machine dependent code(native
code).
The CIL Code and its metadata are loaded into
memory by the CLR. The JIT compiler then
compiles this CIL ode to machine code at runtime.
.NET Framework Classes
The class libraries are responsible for programmatic access to
all available resources within .NET and include ASP.NET,
Enterprise Services, ADO.NET, and Windows Forms.
The .NET class library is a giant repository of classes.
Everything in the .NET Framework is treated as an object.
These objects are placed into logical groups called
namespaces.
For example, all objects that deal with databases are in the
System.Data namespace, all XML objects are in the
System.Xml namespace, and so on. This caused to build
libraries of objects.
namespace
A namespace is a grouping of like objects, Namespaces
make up the .NET Framework class library.
They provide organization for all the re sources available in
the framework.
They also provide scope, so you can have multiple classe s
within your application provided that each class resides in
its own namespace.
The following code sample illustrates how namespaces are
used within .NET:
•Imports System.Web.Services
•Imports System.Diagnostics
Visual Web Developer
Visual
Web Developer is a sophisticated
program for creating, editing, and testing
ASP.NET websites and web.
What Is ASP.NET?
Web pages whose content is determined dynamically based on
user input or other information are called dynamic web pages.
The opposite of a dynamic web page is a static web page.
Static web pages contain content that does not change based
on who visits the page or other external factors.
HTML pages, for example, are static web pages. Consider an
HTML page on a website with the following markup:
<html>
<body> <b>Hello, World!</b>
</body> </html>
Serving Static Web Pages
A web server is a software application that continually waits for
incoming web requests, which are requests for a particular
URL (see Figure 1.1). The web server examines the requested
URL, locates the appropriate file, and then sends this fileback to
the client that made the request.
For example, URL (say, /books/index.html).
How Static web Pages work
Serving Dynamic Web Pages
To accommodate dynamic content, dynamic
web pages contain source code that is
executed when the page is requested
(see Figure 1.2). The executing code
produces the HTML that is sent back to and
displayed in the visitor’s browser.
How Dynamic Web pages work
Hosting ASP.NET Pages
When you’re developing ASP.NET websites, the ASP.NET pages you
create are saved on your personal computer. To test these pages,
then, your computer must have a web server installed.
Visual Web Developer, the editor we’ll be using throughout this
book to create our ASP.NET websites, includes a lightweight web
server specifically designed for testing ASP.NET pages.
http://localhost:portNumber/
ASP.NET_Page.aspx.
The http://localhost portion of the request tells the browser to send
the request to your personal computer’s web server, in contrast to
some other web server on the Internet. The portNumber specifies a
particular port through which the request is made. All web
servers listen for incoming requests on a particular port.
Finally, the ASP.NET_Page.aspx portion is the filename of the
ASP.NET page being tested.
Advantages of Hosting ASP.NET
pages Locally
Hosting ASP.NET pages locally through the ASP.NET Development
Web Server has a number of advantages:
1) Testing can be done while offline
2) . It’s fast
3) Advanced debugging features are available.
4) It’s secure.
Disadvantages
The main disadvantage of hosting ASP.NET pages locally is that they
can be viewed only from your computer.
If you want to create an ASP.NET website that can be visited by
anyone with an Internet connection, you should consider using a
webhosting company.
Solution Explorer
website, the Solution Explorer will list the website’s files. These
files include database files, HTML pages, ASP.NET pages, image
files, CSS files, configuration files, and so on. In addition to the
Solution Explorer, the right portion of the screen is also home to
the Database Explorer.
Creating a New ASP.NET Website
There are several ways to create a new
ASP.NET website from Visual Web
Developer. You can go to the File menu and
choose the New Web Site option; you can
click the New Website icon in the toolbar;
or you can click the New Web Site link
above the Recent Projects pane of the Start
Page.
Creating a New ASP.NET
Website
By default, the New Web Site dialog box should have Visual Basic as
the selected programming language, ASP.NET Web Site as the
selected website template, and the File System option selected in
the Web location drop-down list.
When you are creating a new website using the Empty Web Site
template, Visual Web Developer adds a single configuration file to
the project named web.config. Using other templates causes Visual
Web Developer to add many more files and folders to the new
website.
Creating a Simple ASP.NET
Page
ASP.NET Files
ASP.NET pages are broken into two files: one that contains the HTML
markup and Web control syntax, and another that contains the
source code. If you expand Default.aspx in the Solution Explorer,
you’ll see that there’s another file,Default.aspx.vb. This is the source
code file for Default.aspx.
HTML and Web Controls file
There are three “views” from which you can work with the HTML
elements and Web controls in an ASP.NET page. The first is the
Source view, which shows the page’s HTML markup and Web
control syntax. This is the default view and the one shown in
Figure 1.12. The second view, called the Design view, provides a
simpler alternative to specifying and viewing the page’s content.
In the Design view you can drag and drop HTML elements and
Web controls from the Toolbox onto the design surface. The third
view, Split, divides the screen in half, showing the Source view in
the top portion and the corresponding Design view in the bottom.
Testing the ASP.NET Page
From the Source view, place your cursor between the <div> and
</div> tags in Default.aspx and add the following text:
<h1>Hello, World!</h1>
Summary
Today, virtually all websites contain dynamic web pages of one kind
or another. Any website that allows a user to search its content,
order products, or customize the site’s content is dynamic in
nature.
Today, we took a look at the fundamental concepts of the .NET
framework. The .NET Framework is set of blueprints and objects.
Applications developed within this framework are compiled into
Microsoft Intermediate Language, and they produce meta-data that
describes them.
END