Web application Basics
π· What is a Web Application?
A web application is a software program that runs on a web server and is accessed by users through a web browser using the internet or an intranet.
Unlike traditional desktop applications, web applications do not need to be installed on a userβs machine.
π· Components of a Web Application
-
Client (Front-End)
-
Runs in the user's browser
- Built using HTML, CSS, JavaScript
-
Handles user input, interactions, and display
-
Server (Back-End)
-
Processes business logic
- Communicates with the database
-
Returns data or web pages to the client
-
Database
-
Stores user data, content, and application state
- Commonly used databases: SQL Server, MySQL, Oracle, MongoDB
π· Types of Web Applications
| Type | Description |
|---|---|
| Static Web App | Delivers fixed content (e.g., HTML pages) |
| Dynamic Web App | Generates content dynamically (e.g., ASP.NET) |
| Single Page Application (SPA) | Loads a single HTML page and updates dynamically (e.g., React, Angular) |
| Progressive Web App (PWA) | Works like a native app, supports offline use |
π· Web Application vs Desktop Application
| Feature | Web Application | Desktop Application |
|---|---|---|
| Installation | Not required | Required |
| Accessibility | Accessible via browser | Runs on specific machine |
| Update & Maintenance | Easier (centralized server) | Harder (needs manual update) |
| Performance | Depends on internet & server | High performance on local machine |
π· ASP.NET for Web Development
ASP.NET is a framework developed by Microsoft for building dynamic web applications using .NET languages like VB.NET or C#.
Features:
- Server-side processing
- Web Forms and MVC support
- Session and state management
- Security features like authentication and authorization
- Rich set of controls and libraries
π· Life Cycle of a Web Application Request
- Request: Browser sends an HTTP request to the server.
- Routing: Server routes the request to the correct handler (e.g., a .aspx file or controller).
- Processing: Code runs on the server; data is fetched from DB if needed.
- Response: Server returns an HTML response to the browser.
- Rendering: Browser displays the result to the user.
π· Tools Used for Web Development
- Visual Studio: For ASP.NET development
- IIS (Internet Information Services): Web server for running ASP.NET apps
- Web Browsers: Chrome, Firefox, Edge for testing UI
- SQL Server: Database backend
π· Advantages of Web Applications
- Platform independent (runs in any browser)
- Centralized updates and deployment
- Easy access from anywhere
- Scalable and maintainable
- Cross-device compatibility
π· Real-Life Examples
- Gmail
- Online banking portals
- E-commerce websites like Amazon
- Online reservation systems
- College/student portals
π Summary:
- A web application runs on a server and is accessed via a web browser.
- It has three main parts: Client, Server, and Database.
- ASP.NET is widely used to develop .NET-based web apps.
- Web apps are easier to maintain and update compared to desktop apps.
Web Application Fundamentals
π· What Are Web Application Fundamentals?
Web application fundamentals refer to the core concepts, architecture, and technologies that are essential for building and running web-based applications. Understanding these basics is crucial for developing reliable, scalable, and user-friendly web apps.
πΆ 1. Web Application Architecture
A typical web application is based on the Client-Server Model, consisting of:
| Component | Role |
|---|---|
| Client (Frontend) | User interface part (runs in the web browser) |
| Server (Backend) | Handles business logic and processes client requests |
| Database | Stores data (like users, orders, etc.) |
πΆ 2. HTTP Protocol
- Web apps communicate using HTTP (HyperText Transfer Protocol) or HTTPS (secure).
- It is a stateless protocol, meaning each request is independent and doesnβt remember previous interactions.
Common HTTP Methods:
| Method | Purpose |
|---|---|
GET |
Retrieve data |
POST |
Submit data |
PUT |
Update existing data |
DELETE |
Remove data |
πΆ 3. URL and Routing
- Each web page or functionality has a unique URL (Uniform Resource Locator).
- Routing maps a URL to specific code (e.g., a page or a controller method in ASP.NET).
Example:
https://myapp.com/products β Products.aspx or ProductsController.cs
πΆ 4. Frontend Technologies
The frontend is what the user sees and interacts with. It includes:
| Technology | Purpose |
|---|---|
| HTML | Structure of the page |
| CSS | Styling and layout |
| JavaScript | Interactivity and client-side logic |
Modern frameworks: React, Angular, Vue
πΆ 5. Backend Technologies
Backend processes requests, performs logic, and communicates with databases.
-
In .NET, backend can be built using:
-
ASP.NET Web Forms
- ASP.NET MVC
- ASP.NET Core
It handles:
- Authentication
- Business logic
- Database communication
- Session management
πΆ 6. Databases
Web apps often need to store and retrieve data. Common databases:
| Type | Example |
|---|---|
| Relational | SQL Server, MySQL |
| NoSQL | MongoDB |
In .NET apps, ADO.NET or Entity Framework is used to interact with databases.
πΆ 7. State Management
Since HTTP is stateless, web apps use state management to remember user information across pages.
| Technique | Description |
|---|---|
| Session State | Stores data for one user session |
| Cookies | Small pieces of data stored in the browser |
| ViewState | Stores control values between postbacks (Web Forms) |
| Query Strings | Passes data via URL parameters |
πΆ 8. Security Fundamentals
Web apps must handle security properly. Common measures:
| Security Feature | Purpose |
|---|---|
| Authentication | Verifies user identity (login system) |
| Authorization | Controls what the user can access |
| Input Validation | Prevents SQL injection, XSS, etc. |
| HTTPS | Encrypts communication |
πΆ 9. Development Environment
- Visual Studio: IDE for developing ASP.NET applications
- IIS (Internet Information Services): Web server for running .NET web apps
- .NET Framework / .NET Core: Runtime for executing .NET applications
πΆ 10. Deployment
Web applications are deployed to a web server (like IIS or Azure App Service). Users access it via a browser from anywhere.
π Summary Table
| Concept | Description |
|---|---|
| Web app architecture | Client-server + database |
| HTTP | Stateless communication protocol |
| Frontend | HTML, CSS, JavaScript |
| Backend | ASP.NET handles logic |
| Routing | Maps URLs to code |
| Database | Stores persistent data |
| State management | Maintains user data across pages |
| Security | Protects against threats |
| Tools | Visual Studio, IIS |
| Deployment | Hosting the web app |
ASP.NET Application Fundamentals
π· What is ASP.NET?
ASP.NET is a web application framework developed by Microsoft that allows developers to build dynamic websites, web applications, and web services using .NET languages like VB.NET or C#.
It runs on the .NET Framework (or .NET Core/.NET 5+ in newer versions) and uses the HTTP protocol to communicate between browser (client) and web server.
π· ASP.NET Application Structure
An ASP.NET web application typically includes:
| Component | Description |
|---|---|
.aspx pages |
Web Forms with HTML UI and server-side logic |
.aspx.cs or .vb |
Code-behind files (written in C# or VB.NET) |
web.config |
Configuration settings (e.g., security, session, database) |
Global.asax |
Global application events like start, end, error |
App_Code folder |
Shared classes and utility functions |
App_Data folder |
Databases or data files used by the application |
π· ASP.NET Page Life Cycle
Each time a user requests a page, the ASP.NET engine follows a life cycle:
| Stage | Description |
|---|---|
| Page Request | Client requests a .aspx page |
| Start | Sets properties like IsPostBack |
| Initialization | Controls are initialized (ID set) |
| Load | Loads control properties and view state |
| PostBack Events | Executes user events like button clicks |
| Rendering | Page is converted to HTML |
| Unload | Final cleanup and memory release |
π· Server-Side vs Client-Side
| Server-Side (ASP.NET) | Client-Side (Browser) |
|---|---|
| Code executes on server | Code executes on userβs browser |
| Uses C# / VB.NET | Uses JavaScript / HTML / CSS |
| Secure and hidden | Visible and editable in browser |
| Can connect to database | Cannot directly connect to database |
π· Web Forms in ASP.NET
- Built using
.aspxpages and controls - Drag-and-drop controls from the toolbox (e.g., Button, Label, GridView)
- Use
runat="server"to make controls accessible in code-behind - Event-driven (e.g., Button_Click)
Example:
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
Code-behind:
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblMessage.Text = "Submitted!";
}
π· Key ASP.NET Features
| Feature | Description |
|---|---|
| State Management | Maintains user data using Session, ViewState, Cookies |
| Validation Controls | Validates input (e.g., RequiredFieldValidator) |
| Master Pages | Provides consistent layout for multiple pages |
| Themes and Skins | Provides styling for controls and pages |
| Data Binding | Connects controls like GridView to databases |
| Security | Login controls, roles, membership providers |
π· Configuration with web.config
- Central XML file to store settings
Examples:
- Database connection strings
- Authentication rules
- Custom error pages
- Session settings
<connectionStrings>
<add name="MyDB" connectionString="Data Source=..."/>
</connectionStrings>
π· ASP.NET Compilation Model
- Pages are compiled into assemblies (DLLs) the first time they are accessed.
- Faster execution after first request.
π· Deployment Options
- IIS (Internet Information Services): Microsoftβs web server for hosting ASP.NET apps
- Azure Web Apps: Cloud deployment for ASP.NET
- FTP / Web Deploy: Traditional file transfer
π Summary Table
| Feature | Description |
|---|---|
| ASP.NET | Framework for building web apps using .NET |
| Page Life Cycle | Series of events from request to response |
| Web Forms | Visual, event-driven pages using controls |
| web.config | Stores app settings |
| State Management | Session, ViewState, Cookies |
| Deployment | Via IIS, Azure, or other hosts |