ASP vs. ASP.NET: Comparing Classic ASP and the .NET Framework

This guide compares and contrasts classic ASP and ASP.NET, two web development technologies from Microsoft. Learn about their key differences, understand their strengths and weaknesses, and determine which technology is best suited for your web development projects.



ASP.NET Interview Questions and Answers

What is ASP?

Question 1: What is ASP?

ASP (Active Server Pages) is a server-side scripting technology from Microsoft used to create dynamic web pages. Classic ASP used scripting languages like VBScript to generate HTML content on the server.

What is ASP.NET?

Question 2: What is ASP.NET?

ASP.NET is a web application framework from Microsoft that runs on the .NET platform. It's used to build websites, web services, and web applications, offering improved performance and features compared to classic ASP.

ASP vs. ASP.NET

Question 3: ASP vs. ASP.NET

Key difference:

  • ASP: Interpreted; uses scripting languages (like VBScript).
  • ASP.NET: Compiled; uses .NET languages (like C#, VB.NET); generally offers better performance.

IIS (Internet Information Services)

Question 4: What is IIS?

IIS (Internet Information Services) is Microsoft's web server. It hosts ASP.NET applications and other web content.

IIS Usage

Question 5: IIS Usage

IIS is used to:

  • Host web applications.
  • Manage requests and responses.
  • Provide services such as SMTP (email) and FrontPage extensions.

Multilingual Websites

Question 6: Multilingual Websites

A multilingual website provides content in multiple languages. This requires careful design and implementation to support different languages and locales.

Caching

Question 7: Caching

Caching stores frequently accessed data in memory (or other fast storage) to speed up retrieval. This improves performance but adds overhead.

Caching Requirements

Question 8: Caching Requirements

Considerations for caching:

  • What to cache (frequently accessed, static data).
  • Cache invalidation (how to update cached data).
  • Cache size and management.

Advantages of ASP.NET

Question 9: Advantages of ASP.NET

Advantages over classic ASP:

  • Improved performance (compiled code).
  • Enhanced scalability.
  • Built-in security features.
  • Support for multiple programming languages.
  • Rich set of controls and libraries.
  • Simplified configuration and deployment.
  • Caching mechanisms (page and object caching).

Postbacks

Question 10: Postbacks in ASP.NET

A postback is when a web page sends data back to the server using an HTTP POST request. The server processes the data and typically refreshes the entire page.

`IsPostBack` Property

Question 11: `IsPostBack` Property

The IsPostBack property in ASP.NET indicates whether a page is being loaded for the first time or is being reloaded after a postback.

Identifying Postbacks

Question 12: Identifying Postbacks

Check the value of the `IsPostBack` property.

Parent Class of Web Server Controls

Question 13: Parent Class of Web Server Controls

The base class for all web server controls in ASP.NET is `System.Web.UI.Control`.

Web Forms vs. MVC

Question 14: ASP.NET Web Forms vs. ASP.NET MVC

Differences:

Feature Web Forms MVC
Controller Type Page controller Front controller
Approach Event-driven Request-driven
Testing More challenging to unit test Easier to unit test

GET vs. POST

Question 15: GET vs. POST Methods

Differences:

Method Data Transmission Security Data Size
GET Data appended to URL Less secure Limited
POST Data sent in request body More secure Larger amounts of data

Session vs. Application Objects

Question 16: Session vs. Application Objects

Differences:

Object Scope
Session Per user
Application Entire application

`Debug` vs. `Trace`

Question 17: `Debug` vs. `Trace`

Differences:

  • Debug: For debugging purposes only; not included in release builds.
  • Trace: For both debugging and logging; can be included in release builds.

Client-Side vs. Server-Side Validation

Question 18: Client-Side vs. Server-Side Validation

Client-side validation uses JavaScript (or VBScript); server-side validation uses server-side code. Server-side validation is crucial for security because client-side validation can be easily bypassed.

File-Based vs. Key-Based Dependencies

Question 19: File-Based vs. Key-Based Dependencies

File-based dependencies refer to files on disk; key-based dependencies refer to cached items identified by a key.

Globalization vs. Localization

Question 20: Globalization vs. Localization

Globalization: Designing a system to support multiple languages and cultures. Localization: Adapting a system for a specific language or locale.

Page vs. Global Themes

Question 21: Page vs. Global Themes

A page theme applies to a specific page; a global theme applies across the entire application.

Early vs. Late Binding

Question 22: Early vs. Late Binding

Early Binding (Static): Method to be invoked is known at compile time. Late Binding (Dynamic): Method to be invoked is determined at runtime (used with virtual methods).

Server-Side vs. Client-Side Scripting

Question 23: Server-Side vs. Client-Side Scripting

Server-side scripting (e.g., ASP.NET) executes on the server; client-side scripting (e.g., JavaScript) executes in the user's browser.

Signing Out of Forms Authentication

Question 24: Signing Out of Forms Authentication

C# Code

FormsAuthentication.SignOut();

Displaying Validation Messages

Question 25: Displaying Validation Messages

Use the ValidationSummary control in ASP.NET to display all validation messages in one location.

Authentication vs. Authorization

Question 26: Authentication vs. Authorization

Authentication: Verifying the user's identity. Authorization: Determining what a user is allowed to do.

Session Object

Question 27: Session Object

The session object in ASP.NET stores user-specific information for the duration of a session.

ViewState

Question 28: ViewState

ViewState in ASP.NET preserves page data between postbacks, storing it in a hidden field on the page.

`Response.Write()` vs. `Response.Output.Write()`

Question 30: `Response.Write()` vs. `Response.Output.Write()`

Differences:

  • Response.Write(): Writes directly to the response stream.
  • Response.Output.Write(): Provides more control over output formatting.

Configuration Files

Question 31: Configuration Files

Configuration files in ASP.NET:

  • Web.config (application-level).
  • Machine.config (machine-level).

Web.config vs. Machine.config

Question 32: Web.config vs. Machine.config

Differences:

  • Web.config: Application-level configuration file; settings specific to the web application.
  • Machine.config: Machine-level configuration file; settings apply to all web applications on the server.

Model-View-Controller (MVC)

Question 33: MVC (Model-View-Controller)

MVC is a design pattern that separates application concerns: Model (data), View (presentation), and Controller (handles user requests and updates the model and view).

Built-in ASP.NET Objects

Question 34: Built-in ASP.NET Objects

Important built-in objects:

  • Application: Application-level state.
  • Session: Per-user session state.
  • Context: Provides context information.
  • Request: Client request information.
  • Response: Server response to the client.
  • Server: Provides server-side utilities.
  • Trace: For debugging and logging.

Role-Based Security

Question 35: Role-Based Security

Role-based security assigns permissions to roles, and then users are assigned to those roles. This simplifies access control management.

Cookies

Question 36: Cookies

Cookies are small pieces of data stored on a client's machine. Types:

  • Session cookies: Temporary; expire when the browser closes.
  • Persistent cookies: Stored on the hard drive for a longer period.

Cookie Timeouts

Question 37: Cookie Timeout

The default timeout for a cookie is typically 30 minutes but can be customized.

Disabling Cookies

Question 38: Disabling Cookies

Set the `Cookie.Discard` property to `true` to prevent the cookie from being saved on the client's hard drive at the end of the session.

Web Services Protocol

Question 39: Web Services Protocol

HTTP is the most common protocol for web services.

Web Services File Extension

Question 40: Web Service File Extension

The file extension for an ASP.NET web service is typically `.asmx`.

HTML Server Controls

Question 41: HTML Server Controls

HTML server controls are HTML elements with the `runat="server"` attribute. This makes them accessible to server-side code.

Global.asax

Question 42: Global.asax File

The `Global.asax` file handles application-level events (like application startup and shutdown) and allows you to define application-wide variables.

Event Bubbling

Question 43: Event Bubbling

Event bubbling in ASP.NET refers to how events propagate from a child control up to its parent control.

File-Based vs. Key-Based Dependencies

Question 19: File-Based vs. Key-Based Dependencies

File-based dependencies are references to files on the file system; key-based dependencies are references to items stored in a cache (using a key).

Globalization vs. Localization

Question 20: Globalization vs. Localization

Globalization: Designing a system to support multiple languages and regions. Localization: Adapting a system for a specific language or region.

Page vs. Global Themes

Question 21: Page vs. Global Themes

A page theme applies to a single page; a global theme applies across the entire application.

Early vs. Late Binding

Question 22: Early vs. Late Binding

Early binding: The method call is resolved at compile time. Late binding: The method call is resolved at runtime (polymorphism).

Server-Side vs. Client-Side Scripting

Question 23: Server-Side vs. Client-Side Scripting

Server-side scripts execute on the server; client-side scripts execute in the user's browser.

Signing Out

Question 24: Signing Out of Forms Authentication

C# Code

FormsAuthentication.SignOut();

Validation Summary Control

Question 25: Displaying Validation Messages in One Control

Use the ValidationSummary control in ASP.NET to show all validation errors in a single location.

Authentication vs. Authorization

Question 26: Authentication vs. Authorization

Authentication: Verifying a user's identity. Authorization: Determining what a user is permitted to do.

Session State

Question 27: Session Object

The session object stores user-specific information for the duration of a session.

ViewState

Question 28: ViewState

ViewState in ASP.NET preserves page state between postbacks.

`Response.Write()` vs. `Response.Output.Write()`

Question 30: `Response.Write()` vs. `Response.Output.Write()`

Response.Write() writes directly to the response stream; `Response.Output.Write()` allows for formatted output.

Configuration Files (Continued)

Question 31: Configuration Files (Continued)

The `Web.config` file contains application-specific settings; `Machine.config` holds machine-wide settings.