asp.net banner

ASP.NET Multiple Choice Questions (MCQs) and Answers

Master ASP.NET with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of ASP.NET concepts. Begin your placement preparation journey now!

Q91

Q91 How do you ensure security in a Web API?

A

By using SSL

B

By storing passwords in plaintext

C

By disabling authentication

D

By allowing all IPs

Q92

Q92 How do you return a JSON response from a Web API controller action?

A

return Json(object);

B

return new JsonResult(object);

C

return Ok(object);

D

return JsonResponse(object);

Q93

Q93 How do you specify an HTTP GET method in a Web API controller?

A

[HttpGet]

B

[Get]

C

[HttpVerb("GET")]

D

[HttpRetrieve]

Q94

Q94 How do you handle exceptions in a Web API?

A

By using try-catch blocks

B

By using exception filters

C

By using middleware

D

All of the above

Q95

Q95 Which tool can be used to test Web API endpoints?

A

Fiddler

B

Postman

C

SQL Profiler

D

Route Debugger

Q96

Q96 How can you enable tracing in a Web API application?

A

By using the System.Diagnostics.Trace class

B

By setting Trace="true" in Web.config

C

By adding a trace listener in Global.asax

D

By using tracing middleware

Q97

Q97 What is the primary purpose of SignalR in ASP.NET?

A

To manage databases

B

To create real-time web applications

C

To handle user authentication

D

To optimize performance

Q98

Q98 What is a Hub in SignalR?

A

A database component

B

A security feature

C

A server-side component for handling client connections

D

A caching mechanism

Q99

Q99 Which protocol is preferred for SignalR when available?

A

Long Polling

B

WebSockets

C

Server-Sent Events

D

HTTP

Q100

Q100 How does SignalR handle fallback transport methods?

A

By using only WebSockets

B

By disconnecting the client

C

By automatically switching to supported transport methods

D

By throwing an error

Q101

Q101 What is the main use of the PersistentConnection class in SignalR?

A

To manage database connections

B

To create reusable connections that handle low-level communication details

C

To optimize performance

D

To manage user authentication

Q102

Q102 How do you define a Hub in SignalR?

A

public class MyHub : SignalRHub

B

public class MyHub : Hub

C

public class MyHub : SignalR.Connection

D

public class MyHub : SignalR.Component

Q103

Q103 How do you call a client method from a SignalR Hub using a specific client ID?

A

Clients.Caller.methodName()

B

Clients.Client("clientId").methodName()

C

Clients.Group("groupName").methodName()

D

Clients.All.methodName()

Q104

Q104 How do you handle disconnections in SignalR?

A

By overriding the OnDisconnectedAsync method

B

By using the OnDisconnect event

C

By implementing the IDisconnectHandler interface

D

By using the Disconnect attribute

Q105

Q105 Which tool can be used to monitor SignalR traffic?

A

Fiddler

B

Postman

C

SQL Profiler

D

Browser Developer Tools

Q106

Q106 What is a recommended approach to troubleshoot connection issues in SignalR?

A

By checking server logs

B

By enabling detailed client-side logging

C

By using browser developer tools

D

By testing different transport methods

Q107

Q107 What is the primary purpose of ASP.NET Identity?

A

To manage sessions

B

To handle HTTP requests

C

To provide authentication and authorization

D

To manage database connections

Q108

Q108 What is a role in ASP.NET Identity?

A

A type of database connection

B

A type of user

C

A set of permissions assigned to a user

D

A method of session management

Q109

Q109 Which class is used to manage users in ASP.NET Identity?

A

UserManager

B

RoleManager

C

SignInManager

D

IdentityManager

Q110

Q110 What is the purpose of the SignInManager class in ASP.NET Identity?

A

To create roles

B

To manage user sign-ins

C

To handle database connections

D

To manage user sessions

Q111

Q111 How does ASP.NET Identity store user information by default?

A

In a SQL database

B

In memory

C

In a text file

D

In an XML file

Q112

Q112 How do you create a new user in ASP.NET Identity?

A

userManager.AddUserAsync(user);

B

userManager.CreateAsync(user, password);

C

userManager.AddAsync(user);

D

userManager.NewUserAsync(user, password);

Q113

Q113 How do you add a user to a role in ASP.NET Identity?

A

roleManager.AddUserToRole(user, role);

B

userManager.AddToRoleAsync(user, role);

C

signInManager.AddToRoleAsync(user, role);

D

identityManager.AddUserToRoleAsync(user, role);

Q114

Q114 How do you verify a user password in ASP.NET Identity?

A

userManager.VerifyPassword(user, password);

B

signInManager.CheckPassword(user, password);

C

userManager.CheckPasswordAsync(user, password);

D

identityManager.VerifyPasswordAsync(user, password);

Q115

Q115 Which tool can be used to monitor and debug authentication issues in ASP.NET Identity?

A

Fiddler

B

Postman

C

SQL Profiler

D

Browser Developer Tools

Q116

Q116 How do you handle errors when creating a user in ASP.NET Identity?

A

By logging the errors

B

By showing detailed error messages to the user

C

By using try-catch blocks and checking IdentityResult

D

By ignoring the errors

Q117

Q117 What is the primary purpose of error handling in ASP.NET?

A

To enhance performance

B

To manage user sessions

C

To handle and log application errors

D

To manage databases

Q118

Q118 What is a common method for handling exceptions in ASP.NET?

A

Using if-else statements

B

Using try-catch blocks

C

Using loops

D

Using break statements

Q119

Q119 What is the role of the Global.asax file in error handling?

A

To define CSS styles

B

To handle application-level events and errors

C

To manage database connections

D

To optimize performance

Q120

Q120 What is the purpose of the customErrors element in Web.config?

A

To customize the appearance of a website

B

To manage user roles

C

To define custom error pages

D

To handle database queries

ad verticalad vertical
ad