What are different methods of session maintenance in ASP.NET?
.NET Interview Questions and Answers
(Continued from previous question...)
What are different methods of session maintenance in ASP.NET?
3 types:
In-process storage.
Session State Service.
Microsoft SQL Server.
In-Process Storage
The default location for session state storage is in the ASP.NET process itself.
Session State Service
As an alternative to using in-process storage for session state, ASP.NET provides the ASP.NET State Service. The State Service gives you an out-of-process alternative for storing session state that is not tied quite so closely to ASP.NET’s own process.
To use the State Service, you need to edit the sessionState element in your ASP.NET application’s web.config file:
You’ll also need to start the ASP.NET State Service on the computer that you specified in the stateConnectionString attribute. The .NET Framework installs this service, but by default it’s set to manual startup. If you’re going to depend on it for storing session state, you’ll want to change that to automatic startup by using the Services MMC plug-in in the Administrative Tools group.
If you make these changes, and then repeat the previous set of steps, you’ll see slightly different behavior: session state persists even if you recycle the ASP.NET process.
There are two main advantages to using the State Service. First, it is not running in the same process as ASP.NET, so a crash of ASP.NET will not destroy session information. Second, the stateConnectionString that’s used to locate the State Service includes the TCP/IP address of the service, which need not be running on the same computer as ASP.NET. This allows you to share state information across a web garden (multiple processors on the same computer) or even across a web farm (multiple servers running the application). With the default in-process storage, you can’t share state information between multiple instances of your application.
The major disadvantage of using the State Service is that it’s an external process, rather than part of ASP.NET. That means that reading and writing session state is slower than it would be if you kept the state in-process. And, of course, it’s one more process that you need to manage. As an example of the extra effort that this can entail, there is a bug in the initial release of the State Service that allows a determined attacker to crash the ASP.NET process remotely. If you’re using the State Service to store session state, you should install the patch from Microsoft Security Bulletin MS02-66, or install SP2 for the .NET Framework.
Microsoft SQL Server
The final choice for storing state information is to save it in a Microsoft SQL Server database. To use SQL Server for storing session state, you need to perform several setup steps:
Run the InstallSqlState.sql script on the Microsoft SQL Server where you intend to store session state. This script will create the necessary database and database objects. The .NET Framework installs this script in the same folder as its compilers and other tools–for example, C:\WINNT\Microsoft.NET\Framework\v1.0.3705 on a Windows 2000 computer with the 1.0 version of the Framework.
Edit the sessionState element in the web.config file for your ASP.NET application as follows:
Supply the server name, user name, and password for a SQL Server account that has access to the session state database in the sqlConnectionString attribute.
Like the State Service, SQL Server lets you share session state among the processors in a web garden or the servers in a web farm. But you also get the additional benefit of persistent storage. Even if the computer hosting SQL Server crashes and is restarted, the session state information will still be present in the database, and will be available as soon as the database is running again. That’s because SQL Server, being an industrial-strength database, is designed to log its operations and protect your data at (almost) all costs. If you’re willing to invest in SQL Server clustering, you can keep the session state data available transparently to ASP.NET even if the primary SQL Server computer crashes.
Like the State Service, SQL Server is slower than keeping session state in process. You also need to pay additional licensing fees to use SQL Server for session state in a production application. And, of course, you need to worry about SQL Server-specific threats such as the “Slammer” worm.
(Continued on next question...)
Other Interview Questions
- What is .NET?
- How many languages .NET is supporting now?
- How is .NET able to support multiple languages?
- How ASP .NET different from ASP?
- What is smart navigation?
- What is view state?
- How do you validate the controls in an ASP .NET page?
- Can the validation be done in the server side? Or this can be done only in the Client side?
- How to manage pagination in a page?
- What is ADO .NET and what is difference between ADO and ADO.NET?
- Observations between VB.NET and VC#.NET?
- Advantages of migrating to VB.NET ?
- Advantages of VB.NET
- Using ActiveX Control in .Net
- What is Machine.config?
- What is Web.config?
- What is the difference between ADO and ADO.NET?
- What is the difference between VB and VB.NET?
- What is a Strong Name?
- What is a Manifest?
- Creating a Key Pair?
- What is the difference between "using System.Data;" and directly adding the reference from "Add References Dialog Box"?
- What is GAC?
- What is a Metadata?
- What is managed code and managed data?
- What is .NET / .NET Framework?
- What is Reflection?
- What is "Common Type System" (CTS)?
- What is "Common Language Specification" (CLS)?
- What is "Common Language Runtime" (CLR)?
- What are Attributes?
- What are the Types of Assemblies?
- What is an Intermediate language?
- ASP.NET Authentication Providers and IIS Security
- What is the difference between ASP and ASP.NET?
- Using COM Component in .Net
- What is an assembly?
- What is a Web Service?
- webFarm Vs webGardens
- What is the difference between a namespace and assembly name?
- What’s a Windows process?
- What’s typical about a Windows process in regards to memory allocation?
- Explain what relationship is between a Process, Application Domain, and Application?
- What are possible implementations of distributed applications in .NET?
- What are the consideration in deciding to use .NET Remoting or ASP.NET Web Services?
- What’s a proxy of the server object in .NET Remoting?
- What are remotable objects in .NET Remoting?
- What are channels in .NET Remoting?
- What security measures exist for .NET Remoting in System.Runtime.Remoting?
- What is a formatter?
- Choosing between HTTP and TCP for protocols and Binary and SOAP for formatters, what are the trade-offs?
- What’s SingleCall activation mode used for?
- What’s Singleton activation mode?
- How do you define the lease of the object?
- Can you configure a .NET Remoting object via XML file?
- How can you automatically generate interface for the remotable object in .NET with Microsoft tools?
- What is Delegation?
- What is "Microsoft Intermediate Language" (MSIL)?
- Differences between Datagrid, Datalist and Repeater?
- I am constantly writing the drawing procedures with System.Drawing.Graphics, but having to use the try and dispose blocks is too time-consuming with Graphics objects. Can I automate this?
- How do you trigger the Paint event in System.Drawing?
- With these events, why wouldn’t Microsoft combine Invalidate and Paint, so that you wouldn’t have to tell it to repaint, and then to force it to repaint?
- How can you assign an RGB color to a System.Drawing.Color object?
- What class does Icon derive from? Isn’t it just a Bitmap with a wrapper name around it?
- Before in my VB app I would just load the icons from DLL. How can I load the icons provided by .NET dynamically?
- When displaying fonts, what’s the difference between pixels, points and ems?
- What is the difference between VB 6 and VB.NET?
- What are the authentication methods in .NET?
- What is Serialization in .NET?
- What’s the use of System.Diagnostics.Process class?
- Difference Abstract class and Interface
- re-clarification of object based:
- How to achieve Polymorphism in VB.Net?
- Difference between Class And Interface
- What doesu mean by .NET framework?
- What is assembly?
- What is namespaces?
- NET framework overview
- What is the base class of .NET?
- Explain assemblies.
- Name some of the languages .NET support?
- ADO.NET features? Benefits? Drawbacks?
- How many types of exception handlers are there in .NET?
- Difference between Panel and GroupBox classes?
- What is the base class of Button control?
- What is Response object? How is it related to ASP’s Response object?
- What is IIS? Have you used it?
- Main differences between ASP and ASP.NET.
- What are the advantages and drawbacks of using ADO.NET?
- Why The JavaScript Validation Not Run on the Asp.Net Button But Run SuccessFully On The HTML Button
- what is the difference between user control an custom control? advantages/disadvantages?
- What’s the difference between Response.Write() andResponse.Output.Write()?
- What is the use of ErrorProvider Control?
- What is CLR?
- What is Delegate and what is it used for ?
- How is meant by DLL ?
- Which DLL translate XML to SQL in IIS?
- Can anyone tell me about Secure Socket Layer? How to make use of the technology?
- What is the Differnce Between Response.write & response.output.Write
- Which dll is required to translate XML to SQL in IIS ?
- What is an interface and what is an abstract class? Please, expand by examples of using both. Explain why.
- What is serialization, how it works in .NET?
- What should one do to make class serializable?
- What exactly is being serialized when you perform serialization?
- How does output caching work in ASP.NET?
- What is connection pooling and how do you make your application use it?
- What are different methods of session maintenance in ASP.NET?
- What is Viewstate?
- Can any object be stored in a Viewstate?
- What should you do to store an object in a Viewstate?
- Explain how Viewstate is being formed and how it’s stored on client.
- What do you know about ADO.NET’s objects and methods?
- Explain DataSet.AcceptChanges and DataAdapter.Update methods.
- When we go for html server controls and when we go for web server controls?
- ASP.NET interview questions only (1)
- ASP.NET interview questions only (2)
- ASP.NET interview questions only (3)
|