Learn ASP MCQs

Prepare ASP MCQs (Multiple choice Questions) for exam and job interviews.

What is the purpose of the Master Page in ASP.NET?

1) To provide a layout for content pages

2) To store session variables

3) To connect to a database

4) To handle exceptions

Answer : To provide a layout for content pages

What is the use of the @Page directive?

1) To specify page attributes

2) To define methods

3) To import namespaces

4) To create server controls

Answer : To specify page attributes

What does the method Server.MapPath do?

1) Maps a virtual path to a physical path

2) Creates a session

3) Redirects to another page

4) Generates a URL

Answer : Maps a virtual path to a physical path

Which ASP.NET control is used to upload files?

1) FileUpload

2) UploadControl

3) FileControl

4) UploadFile

Answer : FileUpload

What is the purpose of the SessionState in ASP.NET?

1) To manage user sessions

2) To store application settings

3) To manage database connections

4) To handle exceptions

Answer : To manage user sessions

What does the IsPostBack property check?

1) If the page is being loaded for the first time

2) If a form was submitted

3) If a session is active

4) If a database connection is open

Answer : If the page is being loaded for the first time

What is the primary purpose of the Web.config file?

1) To manage database connections

2) To configure application settings

3) To store session data

4) To define error handling

Answer : To configure application settings

How do you handle exceptions in ASP.NET?

1) Using the try-catch block

2) Using the if statement

3) Using the onerror event

4) Using the error handler

Answer : Using the try-catch block

Which method is used to clear the response buffer in ASP.NET?

1) Response.Clear

2) Response.Reset

3) Response.Flush

4) Response.End

Answer : Response.Clear

How can you include server-side code in an ASP.NET page?

1) <% %>

2) <script runat="server">

3) <%# %>

4) <!DOCTYPE html>

Answer : <% %>