Editor's note: These questions cover classic ASP.NET (.NET Framework), originally published around 2015. Modern development uses ASP.NET Core, which runs cross-platform and replaces Web Forms with Razor Pages, MVC, and Blazor. Some questions below also cover classic ASP.
ASP.NET is Microsoft's framework for building web pages and websites with HTML, CSS, JavaScript, and server-side code. It's used to build interactive, data-driven web applications.
Classic ASP.NET supports three development models: Web Pages, MVC (Model-View-Controller), and Web Forms. Applications are most commonly written in C# or Visual Basic .NET. (Older .NET languages such as J# and JScript .NET are discontinued.)
1. What is ASP?
Active Server Pages (ASP) — now called Classic ASP — is Microsoft's original server-side scripting technology for creating dynamic web pages.
2. What is ASP.NET?
ASP.NET is a development framework for building web pages and websites with HTML, CSS, JavaScript, and server-side code. It succeeded Classic ASP.
3. What are the advantages of ASP.NET over ASP?
- Compiled code
- Support for multiple languages
- Strict coding requirements
- Event-driven programming model
- Third-party controls
- Built-in user authentication
- Easier configuration and deployment
- Object and page caching
- Higher scalability
4. What are the session state storage options in ASP.NET?
- In-process (InProc): The default; session state is stored in the ASP.NET worker process.
- State Server: An out-of-process option using the ASP.NET State Service, so session state survives application restarts.
- SQL Server: Session state is stored in a SQL Server database.
5. What is the difference between Server.Transfer and Response.Redirect?
- Server.Transfer() transfers execution to another page on the server. The browser's URL doesn't change, and there's no extra round trip.
- Response.Redirect() tells the browser to request a new URL. The browser's address bar shows the new page, and it requires an extra round trip.
6. What types of comments can you use in C# code?
- Single-line:
// comment - Multi-line:
/* comment */ - XML documentation:
/// comment
7. What is the @RenderPage() method used for?
In ASP.NET Web Pages (Razor), @RenderPage() imports content from a separate file:
<html>
<body>
@RenderPage("header.cshtml")
<h1>Hello Web Pages</h1>
<p>This is a paragraph</p>
@RenderPage("footer.cshtml")
</body>
</html>
8. What is a typical ASP.NET Web Pages folder structure?
- Account: login and security files
- App_Data: databases and data files
- Images: images
- Scripts: browser scripts
- Shared: common files, such as layout and style files
Files have a virtual name used in URLs (for example, Images/pic31.jpg) and a physical path on the server (for example, C:\Users\Me\Documents\MyWebSites\Demo\Images\pic31.jpg).
9. What is the difference between globalization and localization?
- Globalization is designing and developing software that works across multiple cultures and locales.
- Localization is adapting a globalized application to a specific culture or locale.
10. What is ViewState?
ViewState is how ASP.NET Web Forms preserves page and control values between postbacks. The values are serialized into a Base64-encoded hidden field when the page is rendered.
11. Which method forces all validation controls to run?
Page.Validate()
12. What is the difference between Response.Write() and Response.Output.Write()?
Response.Write() writes unformatted output. Response.Output.Write() lets you write formatted output, similar to String.Format.
13. What is a cookie?
A cookie is a small piece of data the server stores on the user's browser, often used to identify the user. The browser sends it back with each request to the same site.
14. How do you create a cookie?
In Classic ASP, use Response.Cookies (before the <html> tag):
<%
Response.Cookies("fname") = "ABC"
Response.Cookies("fname").Expires = #Jan 10, 2030#
%>
In ASP.NET (C#):
var cookie = new HttpCookie("fname", "ABC");
cookie.Expires = DateTime.Now.AddDays(30);
Response.Cookies.Add(cookie);
15. How do you retrieve a cookie value?
In Classic ASP, use Request.Cookies:
<%
firstname = Request.Cookies("fname")
Response.Write("Firstname=" & firstname)
%>
In ASP.NET (C#): var firstname = Request.Cookies["fname"]?.Value;
Need help with an ASP.NET application or upgrading to ASP.NET Core? I.T. For Less can help — contact us.