Wednesday , October 17 2018
Home / C# Two Years And More Experience Interview Questions

C# Two Years And More Experience Interview Questions

Here I am posting the C# Two Years And More Experience Interview Questions. i  have searched for so many websites and gathered information from my friends to answer the questions perfectly.i think these questions are very helpful for the people who are trying to get the job on .NET  The most common question for One Year Experienced .

1. How is a session maintained?

1. How is a session maintained?

When a web app is requested for the first time, the server creates a sessionID and saves it in the cookie of the client browser. This sessionID is sent to the server in all the subsequent requests. If cookieless is made true, sessionID is sent in the URL else the cookie file is sent. This way the session is maintained with SessionID.

2. When does a session actually start?

2. When does a session actually start?

A session actually starts when a visitor requests your site for the first time. A new session starts when the request doesn’t contain any SessionID or the sessionID references an expired session. The Session_OnStart event in Global.asax can be used for tracking session-related information.

3. What are the various session modes in ASP.NET?

3. What are the various session modes in ASP.NET?

  • In-proc:

    Session data is stored in the same machine as that of the server. So session data is lost, when the server restarts. Session data is overhead on the server.
  • State server: Session data is stored in a separate machine.
  • SQL Server: Session data is stored in a SQL Server database and kept centrally.

4. Name the ActionResults you know?

4. Name the ActionResults you know?

  • View
  • PartialView
  • Content
  • Empty
  • JSON
  • Redirect
  • RedirectToRoute
  • File

5. The default order in which the view is searched?

5. The default order in which the view is searched?

If Home/Index is requested, views will be searched in the following order:

~/Views/Home/Index.cshtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Home/Index.cshtml

6. Session.Abandon() vs Clear()?

6. Session.Abandon() vs Clear()?

Session.Abandon() destroys the current session by firing a Session_End event. It releases the SessionState object and its items to free the resources.

Session.Clear( ) just clears the session data (gives a null value to the session) without killing it. It still holds the SessionState and resources associated with it.

Session ID will remain the same in both of the cases as long as the browser is not closed.

7. What are the various ways to send data from a controller to view?

7. What are the various ways to send data from a controller to view?

 

  • ViewBag: It is a dynamic property.Controller:: ViewBag.Name = “Rasmita”;
    View:: @ViewBag.Name
  • ViewData: It is a Dictionary object derived from the ViewDataDictionary class. It requires type casting and null check for complex data types.Controller:: ViewData[“Name”] = “Rasmita”;
    View:: @ViewData[“Name”]ViewBag and ViewData spans for a server call.
  • TempData: It is a dictionary derived from the TempDataDictionary class. It stores data in a short live session and spans for a HTTP request. It is used when moving from a controller to another or from an action method to another. It is for the current and subsequent request only. It requires type casting and null check for complex data types.

8. What are the various ways to send content from one page to another?

8. What are the various ways to send content from one page to another?

Response. Redirect()
Server.Transfer()
WebClient.DownloadFile()

9. What are Session Modes advantages over the others?

9. What are Session Modes advantages over the others?

InProc: Session data is stored in the same web server. Performance-wise it’s the best mode. But session data will be lost once the server is restarted. Again, since session data is stored in the same server, it’s an overhead on the server, so more data can’t be saved in the session. 

StateServer: Session data is serialized and stored in a separate server so an issue with IIS will not hamper the session data. The aspnet_state.exe service needs to be up and running. Due to serialization and de-serialization, performance-wise it’s slow.

SqlServer: This is a secure and reliable mode. Session data is serialized and saved in a SQL Server database. The overhead is with serializing and de-serializing data. Since data is stored in the database, it’s centrally available. This is preferred if frequent server restartsare needed or data must be shared with multiple servers.

10. What is late binding?

10. What is late binding?

This comes with inheritance and done with the same method name and signature in both the base and child classesd. The Virtual keyword in the base class method and the override keyword in the child class method. This is also known as dynamic polymorphism or method overriding.

Pages ( 1 of 5 ): 1 23 ... 5Next »