Interview Question of .NET

Posted by imomins on October 11, 2011 at 7:20 AM

Cookies

Definition: – A cookie is information that a Website puts on your hard disk so that it can remember something about you at a later time. (More technically, it is information for future use that is stored by the server on the client side of a client/server communication.)

In short, Cookie is client’s information for particular site stored on client’s PC.

Typically, a cookie records your preferences when using a particular site. Using the Web’s Hypertext Transfer Protocol (HTTP), each request for a Web page is independent of all other requests. For this reason, the Web page server has no memory of what pages it has sent to a user previously or anything about your previous visits. A cookie is a mechanism that allows the server to store its own information about a user on the user’s own computer.

 


Procedure:-  following are steps show how cookies works

When you visit some site, server for that site stores information (user name or simply physical address of user’s pc) in 1 text file. For that, that site may ask you to fill details about yourself  or  it can simple fetch physical address of your computer.Server sends this file to client with web page and that file is saved in client’s pc.Now when user visits that website again, that cookie file is also sent to server with the web page request. From that file, website’s sever can identify that particular user and do further procedures (Ex.  Prepare customized webpage for that user) using that information.


Session

Definition: – A session is information of user that a Website puts on its temporary memory so that it can remember something about you when you are visiting that site. (More technically, it is information for future use that is stored by the server on the server side of a client/server communication.)

 In short, Session is client’s information for particular site stored on Server’s temporary memory. The period of time a user interfaces with an application. The user session begins when the user accesses the application and ends when the user quits the application The number of user sessions on a site is used in measuring the amount of traffic a website gets. The site administrator determines what the time frame of a user session will be (e.g., 30 minutes). If the visitor comes back to the site within that time period, it is still considered one user session because any number of visits within those 30 minutes will only count as one session. If the visitor returns to the site after the allotted time period has expired, say an hour from the initial visit, then it is counted as a separate user session. Contrast with unique visitor, hit, click-through and page view, which are all other ways that site administrators measure the amount of traffic a Web site gets. Example:- When you visit www.gmail.com , you have to enter your account ID and password first. That information is verified on server and stored on server in session until that user is logged on.


What is the difference between session and cookie?


If you set the variable to “cookies”, then your users will not have to log in each time they enter your community. The cookie will stay in place within the user’s browser until the user deletes it.

But Sessions are popularly used, as the there is a chance of your cookies getting blocked if the user browser security setting is set high.

If you set the variable to “sessions”, then user activity will be tracked using browser sessions, and your users will have to log in each time they re-open their browser. Additionally, if you are using the “sessions” variable, you need to secure the “sessions” directory, either by placing it above the web root or by requesting that your web host make it a non-browsable directory.

The Key difference would be cookies are stored in your hard disk whereas a session aren’t stored in your hard disk. Sessions are basically like tokens, which are generated at authentication. A session is available as long as the browser is opened.

  1) session should work regardless of the settings on the client browser. even if users decide to forbid the cookie (through browser settings) session still works. there is no way to disable sessions from the client browser.

2) session and cookies differ in type and amount of information they are capable of storing.

Javax.servlet.http.Cookie class has a setValue() method that accepts Strings. javax.servlet.http.HttpSession has a setAttribute() method which takes a String to denote the name and java.lang.Object which means that HttpSession is capable of storing any java object. Cookie can only store String objects

Explain the access specifiers Public, Private, Protected, Friend, Internal, Default?


The main purpose of using access specifiers is to provide security to the applications. The availability (scope)of the member objects of a class may be controlled using access specifiers.

 

1. PUBLIC

As the name specifies, it can be accessed from anywhere. If a member of a class is defined as public then it can be accessed anywhere in the class as well as outside the class. This means that objects can access and modify public fields, properties, methods.

 

2. PRIVATE

As the name suggests, it can't be accessed outside the class. Its the private property of the class and can be accessed only by the members of the class.

 

3. FRIEND/INTERNAL

Friend & Internal mean the same. Friend is used in VB.NET. Internal is used in C#.Friends can be accessed by all classes within an assembly but not from outside the assembly.

 

4. PROTECTED

Protected variables can be used within the class as well as the classes that inherites this class.

 

5. PROTECTED FRIEND/PROTECTED INTERNAL

The Protected Friend can be accessed by Members of the Assembly or the inheriting class, and ofcourse, within the class itself.

 

6. DEFAULT

A Default property is a single property of a class that can be set as the default. This allows developers that use your class to work more easily with your default property because they do not need to make a direct reference to the property. Default properties cannot be initialized as Shared/Static or Private and all must be accepted at least on argument or parameter. Default properties do not promote good code readability, so use this option sparingly.

Whats the difference between Classic ASP and ASP.NET?

Major difference: Classic ASP is Interpreted. ASP.NET is Compiled. If code is changed, ASP.NET recompiles, otherwise does'nt.

Other differences: ASP works with VB as the language. ASP.NET works with VB.NET & C# as the languages (Also supported by other languages that run on the .NET Framework).

ASP.NET is the web technology that comes with the Microsoft .NET Framework. Themain process in ASP.NET is called aspnet_wp.exe that accesses system resources. ASP.NET was launchedin 2002 with version 1.0. Subsequent versions are 1.1 and version 2.0. ASP.NET is built upusing thousands of objects, ordered in the System namespace. When an ASP.NET class is compiled, itscalled an assembly.

In Classic ASP, complex functionalities are achieved using COM components, that are nothingbut component objects created using VB 6, C++ etc, and are usually in a DLL format. Thesecomponents provide an exposed interface to methods in them, to the objects that reference thesecomponents. Last version of classic ASP is version 3.0. ASP has 7 main objects - Application, ASPError, ObjectContext, Request, Response, Server, Session.



 


 

 


 

 

Categories: Personal, C#, ASP.NET

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

0 Comments