Thursday 9 March 2017

ASP.NET interview questions Part-7

1. Ques: What is differentiate between web.config and machine.config files ?
Answer:
Machine.Config
  • Machine.config is configuration file for all the application in the IIS.
  • Machine.config is automatically installed when you install Visual Studio. Net.
  • This is also called machine level configuration file.
  • Only one machine.config file exists on a server.
  • This file is at the highest level in the configuration hierarchy.
  • machine.config would be to share values between many applications on the server such as SMTP server settings
Web.Config
  • Web.config is a configuration file for a particular application or folder.
  • Web.Config is automatically created when you create an ASP.Net web application project.
  • This is also called application level configuration file.
  • This file inherits setting from the machine.config 
  • Web.config files contain application specific items such as database connection strings.

2. Ques: What is Global.asax file in asp.net ? What are the main event and their work in  ASP.Net Application ?
Answer:
The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules. The Global.asax file resides in the root directory of an ASP.NET-based application.The Global.asax file is parsed and dynamically compiled by ASP.NET.The Global.asax file itself is configured so that any direct URL request for it is automatically rejected; external users cannot download or view the code written within it.

Main event in global.asax in given bellow.

Application_Start() 
Application_Start() event occurs when the application starts, which is the first time it receives a request from any user. It doesn’t occur on subsequent requests. This event is commonly used to create or cache some initial information that will be reused later.

Application_End()
Application_End() event occurs when the application is shutting down, generally because the web server has restarted. You can insert cleanup code here.

Application_BeginRequest()
Application_BeginRequest() event occurs with each request the application receives, just before the page code is executed.

Application_EndRequest()
Application_EndRequest() event occurs with each request the application receives, just after the page code is executed.

Session_Start()
Session_Start() event occurs whenever a new user request is received and a session is started.

Session_End()
Session_End() event occurs when a session times out or is pro grammatically ended. This event is only raised if you are using in-process session state storage (the InProc mode, not the StateServer or SQLServer modes ).

Application_Error()
Application_Error() event occurs in response to an un-handled error.


3. Ques: What is a Cookieless Session in ASP.Net?
Answer:
You can configure your application to store Session IDs not in a cookie, but in the URLs of pages in your site. By keeping the Session ID in the URL, ASP.NET stores the ID in the browser, in a manner of speaking, and can get it back when the user requests another page. Cookieless sessions can get around the problem of a browser that refuses cookies and allow you to work with Session state.

ASP.NET Session State by default uses a cookie to store session ID. Session ID is a unique string, used to recognize individual visitor between visits. But, if client's web browser doesn't support cookies or visitor has disabled cookies in web browser's settings, ASP.NET can't store session id on client's machine. In this case, new session will be created for every request. This behavior is useless because we can't remember information for certain visitor between two requests. We can say that, by default, sessions can't work if browser doesn't support cookies.

4. Ques:  What is Tracing in ASP.Net ?
Answer:
Tracing is a way to monitor the execution of your ASP.NET application.ASP.NET tracing enables you to follow a page's execution path, display diagnostic information at run time, and debug your application.
here are two ways to implement Tracing in ASP.Net :

Page Level Tracing
Application Level Tracing

Page level Tracing - Enabled on a page-by-page basis by adding "Trace=true" to the Page directive
Application Tracing - You can enable tracing for the entire application by adding tracing settings in web.config. In below example, pageOutput="false" and requestLimit="20"


5. Ques: What is the Difference between Client Side and Server Side Code?
Answer:
Client Side
  • The client-side environment used to run scripts in a browser. 
  • Code is written in a scripting language such as JavaScript and HTML.
  • The browser itself executes the code in response to a user action and no server round trip is involved.
  • Client browser executes code to dynamically modify the HTML. This is called Dynamic HTML.
  • Code is script and therefore it is interpreted.
Server Side
  • The server-side environment that runs a language in a web server. 
  • Code is written in VB, C# or other compiled languages.
  • Code is executed by the server during a roundtrip in response to a user request or action.
  • The server executes server side code and returns HTML code to the client browser for display.
  • Code is either compiled dynamically or precompiled into assemblies.

6. Ques:  What are the different types of IIS Isolation Levels in ASP.Net?
Answer:
IIS5 supports three isolation levels

Low (IIS Process)

  • ASP pages run in INetInfo.Exe, the main IIS process
  • ASP crashes, IIS crashes
Medium (Pooled)

  • ASP runs in a different process, which makes this setting more reliable
  • If ASP crashes IIS won't.
High (Isolated)

  • Each ASP application runs out-process in its own process space
  • If an ASP application crashes, neither IIS nor any other ASP application will be affected

No comments:

Post a Comment

Thank you for comment