ASP.NET MVC Interview Questions with Answers

ASP.NET MVC Interview Questions with Answers
4.61 (974 reviews)
Udemy
platform
English
language
Web Development
category
ASP.NET MVC Interview Questions with Answers
6 880
students
3.5 hours
content
Sep 2023
last update
$19.99
regular price

Why take this course?

  1. Question 31: Sessions variables in ASP.NET are application-specific and not shared between users. Each user's session is unique to their connection and is stored server-side.

  2. Question 32: Session variables can use cookies, which store a session identifier that is sent back to the server with each request to maintain the state of the user's session. Cookies are not the only method to manage sessions; URL parameters or in-memory storage are also options.

  3. Question 33: A cookie is a small piece of data that a server sends to the user's web browser. The browser may store it and send it back with subsequent requests to the same servers. Typically, each cookie contains the name of a server variable plus an equal sign (=) followed by the value of the cookie.

  4. Question 34: Idle time out in sessions refers to the period after which a session is automatically terminated if there is no activity from the user. This is a security measure to ensure that a user's session does not remain active indefinitely if they have finished their work or are no longer using the application.

  5. Question 35: In HTTP, a context refers to the runtime environment of a client within which an exchange occurs. It includes data about the request, the response, and the underlying protocols and connections.

  6. Question 36: HttpContext is a class in ASP.NET that provides access to the current running context's HTTP request, response, session, server, and application objects within an ASP.NET Web Form or MVC application. It serves as a bridge between the server-side code and the HTTP protocol.

  7. Question 37: HttpSessionState is a class in ASP.NET that represents the current state of a user's session, including the ability to store data that persists across page requests from the same browser. This state can be stored in server memory (in-process), in a SQL Server database (SQLServer mode), or in cookie-based storage (Cookie mode).

  8. Question 38: Session is an object that represents user-specific data that can be stored on the server and retrieved during subsequent requests from the same client session. The Session object is accessed via the HttpContext.Session property in ASP.NET MVC or Web Forms applications.

  9. Question 39: The Session_Start event in ASP.NET is triggered when a user's session begins, providing a means to initialize the user's session and store data that may be used throughout the session.

  10. Question 40: Session variables can hold any type of object that is serializable because they are stored in a context that is not always running (the session state). Non-serializable objects, like databases or open file handles, cannot be stored in a session.

  11. Question 41: Session["key"] is used to access a specific item within the current user's session state in ASP.NET Web Forms. In ASP.NET MVC, you would typically use a TempData or ViewData for similar purposes, depending on the scope of the data (session vs. request).

  12. Question 42: The Session object can be accessed from any page or user control within the same session by using the HttpContext.Current.Session property, as long as the session state is enabled and properly configured.

  13. Question 43: Session state can be lost due to several reasons, such as:

  • The session times out due to inactivity.
  • The session state mode is set to "Off" or "Cookieless," or the cookie is disabled.
  • A web farm configuration where sessions are not shared across multiple servers.
  • IIS recycling or server restarts.
  1. Question 44: To preserve session state across different servers in a web farm, you can use SQL Server mode with a state service like SQL Server to store session data, or you can use cookie-based session state store and ensure the cookie is accessible from all servers.

  2. Question 45: Session security can be compromised if an attacker steals the session cookie or if server-side session management is improperly configured. To enhance security, consider using secure cookies (transmitted over HTTPS), implementing anti-forgery tokens, and regularly checking for signs of session hijacking.

  3. Question 46: To clear a user's session, you can set each value in the session to null or remove it explicitly using Session.Remove["key"], and then call Session.Clear() or Session.Abandon(). After this, the session will end after the appropriate timeout period.

  4. Question 47: Session state mode can be configured in the web application's configuration file (web.config) or through code in the Global.asax file. The modes include "InProc" (process-based), "StateServer" (ASP.NET State Service), "SQLServer" (SQL Server cache), and "Custom" (user-defined state provider).

  5. Question 48: Session locks can cause performance issues in high-traffic scenarios because they prevent other requests from accessing session data when a session is being updated. To mitigate this, consider using a distributed caching system like Redis or Memcached.

  6. Question 49: Cookieless sessions are supported by setting the sessionState element's cookieMode attribute to "UseCookies" in the web application's configuration file and ensuring that the httpCookieBasedSessionId is set to "true."

  7. Question 50: Storing sensitive data in sessions is generally not recommended due to the potential for session hijacking. If you must store sensitive data, ensure it is encrypted and consider additional measures such as user re-authentication or token-based authentication for critical actions.

Loading charts...

4081184
udemy ID
27/05/2021
course created date
13/07/2021
course indexed date
Bot
course submited by