We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Monday, May 11, 2015

Common Interview questions and answers of ASP.NET


1. Where can we find implementation of Http?

-it is implemented as one of service in webserver(like IIS)
-it is in the form of WWWService

2.What is behavior of Http protocol?

-it is implemented as connection less and stateless protocol
-when ever user makes a request connection is established based on ip address of client, once response has been sent automatically connection will be closed
so it is called as connectionless
-every request received will be treated as new request from new user only, so it is called as stateless

3.What is the purpose of State management features in Web Technology?

-Http protocol has been implemented as stateless protocol, so there is a need of some features in web technology to maintain state of user either at client or at server.

4.What are the state management techniques in Asp.net?

-cookies
-Session
-QueryString
-ViewState
-Cacheing
-Application

5.What is Cookie?

-cookie is small packet of information maintained by website at client system.
-Memory allocation for cookie will be done at client system.
-all cookies of website are transmitted between client and server along with request and response in the form of cookies collection.

6 .What type of Data can be stored in cookie?

-only simple plain text can be maintained in cookie

7.How many cookies are allowed for website at client system?

-according to w3c at the maximum 20 cookies allowed, but it totally dependent upon Brower
-most of browsers supports 5 to 8 cookies only

8.How the cookies are transmitted between client and server?

-in the form of cookies collection along with request and response

9.Where can we use cookies in website?

-we can make use of cookies in any webpage in website

10.What the maximum amount of data that can be stored with the help of cookies?

-Maximum size will be upto 4kb only
-all cookies of a website will be maintained in separate cookie file and its max size will be 4kb

11.What is Dictionary?

-if a cookie contains multiple values in the form of key, value then it is called as multi value cookie or dictionary

12.What is the Advantages of Dictionary?

-it will take less memory as compared to multiple cookies with single value
-we can overcome the limitation of number of cookies allowed for website, since we can maintain multiple values with help of single cookie

13. How can we verify whether cookie is dictionary or not?

-By using HasKeys property
-if cookie is dictionary then HasKeys will be true, otherwise it will be false

14. Maximum number of permanent cookies allowed in client system?

-At the maximum 300 cookies are allowed in client system

15.How to create a cookie in asp.net website?

-By using HttpCookie class object
-After creating cookie it will be attached to Response Object to send it to client
Ex: HttpCookie c1=new HttpCookie("Username","Rama");
Response.Cookies.Add(c1);

16.What are the disadvantages of cookies?

-Cookies are maintained at client system, so that they are not secure
-Limited number of cookies are allowed for website(Max 20)
-Limited amount of data can be maintained(Max 4kb)
-Only plain text can be maintained

17. Where can you find usage of cookies in your development?

-To maintain authentication details we can make use of authentication cookie
-To transmit session id between client and server

18. What the default authentication cookie name?

.ASPXAUTH

19. What is cookie name used for transmitting session id between client and server?

asp.net_sessionId

20. How to disable cookies in client browser?

-We can make use of browser options, it depends on browser

21. Where the memory for temporary cookie is allocated?

-As part of browser process memory, so it is also called as in memory cookie or in process cookie

22.what are the different types of cookies?

-There are two types of cookies
1)Temporary cookie or Non-Persistent Cookie
2)Permanent cookie or Persistent Cookie

23.What is session?

-Session is small block of memory maintained by website at server system
-for every user separate session will be maintained
-Each session can be tracked by using sessionid

24.What is the length of sessionId?

-120bit encrypted string

25.What type of data can be stored in the session?

-Any type of data can be stored

26.How much amount of data can be stored in Session?

-any amount of data can be stored

27.What is default location for session?

-In appDomain of website which is part process memory of asp.net worker process
-for each website separate appDomain will be maintained

28.In asp.net page how can we access session data?

- By using Session collection

29.What is default timeout for session?

-20mins

30.How to transmitt sessionid between client and server?

-sessionid can be transmitted in two ways
1)by using cookie:sessionid will be transmitted by using a cookie called aspnet_sessionid
disadvantage:
if browser does not support cookies or user has disabled the cookies then it is not possible to hold session.
2)Modified URL: the sessionid will be attached to url of website,then it is called as modified url or munged URL

31.How to configure session for application?

-By using SessionState element in Web.config


32.When session will be destroyed?

-When ever session timeout period has been expired
-When ever webserver has been restarted or web.config file content has been modified
-Session can be destroyed intensionally by invoking Session.Abandon()

33.If user closes browser window, then is session of user is get destroyed or not?

-no,session memory is not destroyed. But user can not access session data. Once browser has been closed we are loosing sessionid so that session can not be accessed.
Session memory will be destroyed once session timeout period has been expired

34.What are the events associated with session?

1)Session_Start:it will be fired once session memory has been allocated
2)Session_End:it will be fired before destroying session memory by garbage collector.Both these event handlers are defined in global.asax file

35.What is the difference between Session.Clear() and Session.Abandon()?

-Session.Clear() will clear all items of session,but session memory is not destroyed.So that session_End event is not fired
-Session.Abandon() will destroy the complete session memory so that Sesion_End event will be fired

36.What are the different session modes?

There are 5 modes
1)Off:it will disable sessionstate for complete website
2)InProc:it is default mode.Session memory will be allocated in appdomain of website
Advantage:it gives better performance
Disadvantage:-if trafic is more for website, session may not be maintained for specified timeout period
-To allocate memory for new session older sessions will be destroyed automatically
3)StateServer:Asp.net Stateserver is windows service .some of sessions with simple data can be moved to state server
Disadvantage:
-only session with value types can be stored, but not reference types
4)SqlServer: A session with any type of data can be stored in SqlServer TempDb tables temporary for longer time,but they will be losted once sqlserver has been restarted
Disadvantage:
1.Extra burdan of serialization and deserialization
2.It gives nearly 25% less performance as compared to InProc mode
5)Custom:We can maintain session any type of data permanently by creating our own tables and database in sqlserver
Disadvantage:
1.Extra burdan of serialization and deserialization
2.It gives nearly 25% less performance as compared to InProc mode

37.Where can we use session data in our website?

-in any webpage for same user

38.Is it possible to use session of asp.net website in asp website?

-yes,it is posible

No comments: