Search This Blog

Thursday 24 July 2014

All Dotnet Interview Questions 200-250

Question 201 - What are the Advantages of Session?
·         It helps to maintain user states and data to all over the application.
·         It can easily be implemented and we can store any kind of object. 
·         Stores every client data separately.
·         Session is secure and transparent from user.

Question 202 - What are the Disadvantages of Session?
·         Performance overhead in case of large volume of user, because of session data stored in server memory.
·         Overhead involved in serializing and De-Serializing session Data, because In case of State Server and SQL Server session mode we need to serialize the object before store.

Question 203 - What is an In Proc Mode of storing sessions?
In this mode Session, state is stored in the memory space of the Aspnet_wp.exe process. This is the default setting. If the IIS reboots or web application restarts then session state is lost.

Question 204 - What are the Advantages of InProc Sessions?
·         It store Session data in memory object of current application domain. So accessing data is very fast and data is easily available.
·         There is not requirements of serialization to store data in InProc Session Mode.
·         Implementation is very easy, just similar to using View State.

Question 205 - What are the Disadvantages of InProc Sessions?
·         If the worker Process or application domain recycles all session data will be lost.
·         Though its fastest, but more session data and more users can affects performance, because of memory.
·         we can't use it in web Garden scenarios .
·         This session mode is not suitable for web farm scenarios also.
Question 206 - What is a State Server Mode of Storing Sessions?
In this mode Session state is serialized and stored in a separate process (Aspnet_state.exe); therefore, the state can be stored on a separate computer (a state server).

Question 207 - What are the Advantages of State Server Session?
·         Its keeps the data separate from IIS so, any Issue with IIS does not hamper Session data.
·         It is useful in web farm and web garden scenarios.

Question 208 - What are the Disadvantages of State Server Session?
·         Process is slow due to Serialization and De-Serialization
·         State Server always need to be up and running.

Question 209 - What is a SQL Server Mode of Storing Session?
·         In this mode Session, state is serialized and stored in a SQL Server database.
·         SQL Server Session mode is more reliable and secure session state management.
·         Its keeps data in a centralized location (database).
·         We should use SQL server session mode when we need to implement Session with some more security.
·         If  there happens to be  frequent server Restart we can implement SQL server.
·         This is perfect mode that fits in web farm and web garden scenarios (I have explained in details later).
·         we can use SQL server Session mode when we need to share session between two different application.

Question 210 - What are the Advantages of SQL Server mode Session?
·         Session data do not affected if we restart the IIS.
·         It is the most reliable and secure session management.
·         It keeps data located centrally, It can be easily accessible from other application.
·         It is very useful in web farm and web garden scenarios.
Question 211 - What are the Disadvantages of SQL Server modes?
·         Processing is very slow in nature.
·         Object serialization and de-serialization creates overhead for application.
·         As the session data is handled in different server, so we have to take care of SQL server. It should be always up and running.

Question 212 - What is Custom Session Mode in ASP.Net?
·         We can use custom session mode in following of the cases,
·         We want to store session data rather than SQL Server.
·         When we have to use some Existing table to store session data.
·         When we need to create our own session ID.

Question 213 - What are the Advantages of using Custom Session Mode in ASP.Net?
·         It is useful when we have to use some old database rather than SQL Server.
·         It's not depending on IIS , So Restarting web server does not make any effects on session data.
·         We can create our own algorithm for generating Session ID.

Question 214 - What are the Disadvantages of using Custom Session Mode in ASP.Net?
·         Processing of Data is very slow.
·         Creating a custom state provider is a low-level task that needs to be handled carefully to ensure security.

Question 215 - What is a Query String in ASP.Net?
·         QueryString is way to transfer information from one page to another through the URL.
·         QueryString is attached to the URL with "?".
Question 216 - What are the Benefits of a Query String in ASP.Net?
·         Supported by all the browsers
·         No extra effort is needed to code.
·         Easy to use.

Question 217 - What are the Limitations of a Query String in ASP.Net?
·         All the attributes and values are visible to the end user. Therefore, they are not secure.
·         There is a limit to URL length of 255 characters.

Question 218 - What is Cross Page Posting in ASP.Net?
·         Sometimes, other than round-trip cycle of asp.net web page we need to post one page to another page by configuring controls to be posted to different target page. This is referenced as cross page posting in ASP.NET.
·         Cross page posting is a new feature introduced in ASP.NET 2.0, which eases the life of developers previously they have to use Server.Transfer which has its own advantages and disadvantages but now this is a part of ASP.NET which results flexibility and efficiency.

Question 219 - What is SQL Cache Dependency  in ASP.Net?
It is a new technique in ASP.NET 2.0 which can automatically invalidate a cached data object just like a Dataset. when the related data is modified in the database. So for instance if you have a dataset which is tied up to a database tables any changes in the database table will invalidate the cached data object which can be a dataset or a data source.
To enable this we need a syntax that is as follows:-
aspnet_regsql -ed -E -d Northwind
-ed :- command-line switch
-E: - Use trusted connection
-S: - Specify server name it other than the current computer you are working on
-d: - Database Name

Question 220 - What is Global.asax in ASP.Net?
·         It used to implement session level and application level events raised by ASP.net or by HTTP modules.
·         It is also known as ASP.net application file and resides in the root directory of the ASP.NET application.
·         Events available with global.asax are as follows
Question 221 - What are the Event available in Global.asax?
Events
Description
Application_Init
Fired when an application initializes or is first called. It's invoked for all HttpApplication object instances.
Application_Start
Fired when first instance of the HttpApplication class is created. It allows to create objects that are accessible by all HttpApplication instances.
Session_Start
Fired when a new user visits the application Web site.
Application_BeginRequest
Fired when an application request is received. It's the first eventfired for a request, which is often a page request (URL) that a user enters.
Application_EndRequest
The last event fired for an application request.
Application_AuthenticateRequest
Fired when the security module has established the current user'sidentity as valid. Here, the user's credentials have been validated.
Application_Error
Fired when an unhandled exception is encountered within theapplication.
Session_End
Fired when a user's session times out, ends, or they leave theapplication Web site.
Application_End
Fired when the last instance of an HttpApplication class isdestroyed. It's fired only once during an application's lifetime.

Question 222 - What is Caching in ASP.Net?
·         Caching is a technique where we can store frequently used data and Web pages are stored temporarily on local hard disks for later retrieval.
·         This technique improves the access time when multiple users access a Web site simultaneously or a single user accesses a Web site multiple times.
·         Caching can occur on the client (browser caching), on a server between the client and the Web server (proxy / Reverse Proxy Caching), and on the Web server itself (page or data caching).
·         We can classified caching location in 4 way
§  Client Caching (Client Browser)
§  Proxy Caching (In between Client and Server)
§  Reverse Proxy Caching (In between Client and Server)
§  Web Server Caching (Data Caching/ Page Output Caching)

Question 223 - What are the Types of Caching in ASP.Net?
·         Page Output caching [Output caching ] - Is used to fetch information or data at page level. It is best used when the site is mainly static. Used by declaring the output page directive
·         Fragment caching [Output caching ] - Is used to cache the structure level information. It is used when parts of pages change. For example: user control
·         Data Caching - Is used to fetch the information of an application quickly based on the requirements.

Question 224 - How to cache different versions of the same page in ASP.Net?
·         The ways to cache different versions on the same page using ASP.NET cache object is using OutputCache object. Three parameters of OutputCache, has 3 parameters:
·         VarByParam: based on input parameters passed through HTTP POST/GET.
·         VarByHeader: based on the page header content.
·         VayByCustom: based on declaration of an attribute and overriding GetVaryByCustomString handler.
·         VarByControl: varies with the value of properties of ASP objects.

Question 225 - What is a Fragment Cache in ASP.Net?
It is used to store user controls individually within a web form in cache instead of the whole web form as such. The idea is to simply have different cache parameters for different user controls.
control1: <%@ OutputCache Duration="40" VaryByParam="none"%>
control2: <%@ OutputCache Duration="60" VaryByParam="none"%>
If control1 and control2 exist on a single web form together, the values of control1 and control2 would be cached for different durations based on @OutputCache directive.
Question 226 - What are Resource Files in ASP.Net?
·         A resource file is a XML file that contains the strings that we want to Translate into different languages.
·         Can be updated dynamically so that user themselves can modify values in resource files once the application is deployed on the server without re-compiling the entire application itself.
·         The resource file contains key / value pairs.
§  Each pair is an individual resource.
§  Key names are not case sensitive.

Question 227 - What are the Types of Resource Files available in ASP.Net?
There are two types of resources
·         Local Resources
·         Global Resources

Question 228 - What is a Local Resource File in ASP.Net?
·         It is specific to a single Web page and used for providing versions of a Web page in different languages.
·         It must be stored in App_LocalResources sub folder.
·         It must be named in format <WebPageName> [.language / language and culture].resx.

Question 229 - What is a Global Resource File in ASP.Net?
·         Global resource can be read from any page or code that is in the application.
·         Global resource must be stored in App_GlobalResources at the root of the application.

Question 230 - What are the main tags in Web.Config file of ASP.Net application?
<authentication> - This element is used to verify the client's identity when the client requests a page from the server. This is set at the application level. We have four types of authentication modes: “None”, “Windows”, “Forms”, and “Passport”.
<authorization> - The <authorization> tag controls client access to web page resources. This element can be declared at any level (machine, site, application, subdirectory, or page).
<authorization>
<allow users="comma-separated list of users"
roles="comma-separated list of roles"
verbs="comma-separated list of verbs"/>
<deny users="comma-separated list of users"
roles="comma-separated list of roles"
verbs="comma-separated list of verbs"/>
</authorization>
<allow>: Using this tag, we can control access to resources on the basis of the following verbs. In these attributes, we use symbols: ? and *.? means for anonymous users/resources, and * means for all users.
users: This contains the list of user names (comma separated) that are allowed to access the resources.
roles: This contains the list of roles (comma separated) that are allowed to access the resources.
verbs: This contains the list of HTTP verbs to which the action applies (comma separated). It is used to create a rule that applies to a specific type of HTTP request (GET, POST, HEAD, OR DEBUG).
<deny>: Using this tag, we can control access to resources on the basis of the following verbs:
users: This contains the list of users names (comma separated) that are denied access to the resources.
roles: This contains the list of roles (comma separated) that are denied access to the resources.
verbs: This contains the list of HTTP verbs to which the action applies (comma separated). It is used to create a rule that applies to a specific type of HTTP request (GET, POST, HEAD, OR DEBUG).
Question 231 - What is the use of <compilation> tag in ASP.Net Web.Config File?
·         Compilation tag configure the settings of the compiler.
·         debug and defaultLanguage are the common attributes used.
·         Setting debug to true means we want the debugging information in the browser, but it has a performance tradeoff, so normally, it is set as false.
·         The defaultLanguage attribute tells ASP.NET which language compiler to use: VB or C#.

Question 232 - What is the use of <customErrors> tag in ASP.Net Web.Config File?
·         Custom Error tags includes the error settings for the application, and is used to give custom error pages (user-friendly error pages) to end users.
·         If an error occurs then, the website is redirected to the default URL.
·         For enabling and disabling custom errors, we need to specify the mode attribute.
·         Example of <customErrors> tag:
<customErrors defaultRedirect="url" mode="Off">
  <error statusCode="403" redirect="/accesdenied.html" />
  <error statusCode="404" redirect="/pagenotfound.html" />
</customErrors>
·         "On" means if there is any error, the website is redirected to the default URL.
"Off" means the custom errors are disabled.
"RemoteOnly" shows that custom errors will be shown to remote clients only.

Question 233 - What is the use of <globalization> tag in ASP.Net Web.Config File?
·         Globalization tag is used when we want to use encoding or specify a culture for the application.
·         We need to define the character set for the server to send the response to the client, which is by default is UTF-8, and the settings of which the server should use to interpret and display culturally specific strings, such as numbers and dates.
·         Example of <globalization> tag
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />

Question 234 - What is the use of <httpRuntime> tag in ASP.Net Web.Config File?
·         Httpruntime tag can be used to configure the general runtime settings of the application.
The 2 main settings are: <httpRuntime appRequestQueueLimit="50" executionTimeout="600" />
·         The appRequestQueueLimit attribute defines the number of requests that can be queued up on the server for processing. If there are 51 or more requests, then server would return the 503 error ("Server too busy").
·         The executionTimeout attribute defines the number of minutes ASP.NET will process a request before it gets timeout.

Question 235 - What is the use of <trace> tag in ASP.Net Web.Config File?
·         Trace tag is used for tracing the execution of an application.
·         We have here two levels of tracing: page level and application level.
·         Application level enables the trace log of the execution of every page available in the application. If pageOutput="true", trace information will be displayed at the bottom of each page. Else, we can view the trace log in the application root folder, under the name trace.axd.
·         Example of <trace> tag
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />
Set the attribute localOnly to false for not viewing the trace information from the client. For enabling trace at page level, set Trace="True" in the Page tag (on the top of the page).
Question 236 - What is the use of <identity> tag in ASP.Net Web.Config File?
Identity tag is used to control the identity of the application. By default, Impersonation is disabled. Using Impersonation, an ASP.NET application can execute optionally with the identity of a client on whose behalf they are operating.
<identity impersonate="false" userName="domain\username" password="password" />

Question 237 - What is the use of <sessionState> tag in ASP.Net Web.Config File?
·         Sessionstage tag is used to tell the ASP.NET framework where to store the session. By default, it's inproc which means storing the session values on the server. But we have four options:
·         "Off" means session is not enabled for the application.
"inproc" means storing the session values on the server.
"StateServer" means session states are stored in a remote server.
"SQLServer" means session states are stored in a SQL Server database. For this, we need to install the InstallSQLState.sql script in the SQL Server database. It is mainly used when the we use web farms (an application deployed on multiple servers), but it makes the performance slow as compared to "inproc".
·         Other Basic Settings:
"cookieless": when it is true, it means the session used is without cookies.
“timeout” specifies after how much time the session would expire 
"stateConnectionString" needs to be specified when the session mode is StateServer.
"sqlConnectionString" is connection string of the SQL Server database if the session mode is SQLServer.
"stateNetworkTimeout" attribute, when using the StateServer mode to store session state, specifies the number of seconds the TCP/IP network connection between the web server and the state server can be idle before the session is abandoned. The default is 10.
·         Example
<sessionState mode="Off"   cookieless="true"
     timeout="100"
     stateConnectionString="tcpip=server:port"
     sqlConnectionString="sql connection string"
     stateNetworkTimeout="number of seconds"/>
    
Question 238 - What is the use of <appSettings> tag in ASP.Net Web.Config File?
·         AppSetting tag is used to store custom application configuration like database connection strings, file paths etc.
·         This also can be used for custom application-wide constants to store information over multiple pages. It is based on the requirements of the application.
·         Example:
<appSettings>
    <add key="Emailto" value="me@microsoft.com" />
    <add key="cssFile" value="CSS/text.css" />
</appSettings>
It can be accessed from code like:
ConfigurationSettings.AppSettings("Emailto"); All the values returned from it are strings.

Question 239 - What is HTTP GET in ASP.Net?
·         In HTTP GET method data passed through url QueryString using name value pair. It’s simpler and you can troubleshoot any problems simply by looking at the address bar in your browser because all values passed are displayed there.
·         This is also the primary weakness of this method. The data being passed is visible and is limited in size to the maximum length of a request string.

Question 240 - What is HTTP POST in ASP.Net?
·         In HTTP POST request data are embedded in a HTTP HEADER.  So data are NOT visible to end user while you can see the data passed in HTTP GET method. 
·         If you want to pass sensitive information/data, you should have to use HTTP POST request. Another advantage is that you can send larger amounts of information compare to HTTP GET method.
Question 241 – What is Normalization in SQL Server?
·         In relational database design, the process of organizing data to minimize redundancy is called normalization.
·         It usually involves dividing a database into 2 or more tables and defining relationships between tables.
·         Objective is to isolate data so that additions, deletions, and modifications can be made in just one table.

Question 242 – What is a De-Normalization in SQL Server?
It is a technique to move from higher to lower normal forms of database modeling in order to speed up database access.

Question 243 – What are the different Normalization Forms in SQL Server?
·         1NF: Eliminate Repeating Groups
·         2NF: Eliminate Redundant Data
·         3NF: Eliminate Columns Not Dependent On Key
·         4NF: Isolate Independent Multiple Relationships
·         5NF: Isolate Semantically Related Multiple Relationships

Question 244 – What is a Stored Procedure in SQL Server?
·         It is a named group of SQL statements created and stored in the database.
·         Accept input parameters so that single procedure can be used by several clients using different inputs.
·         When the procedure is modified, all clients automatically get the new version.
·         It reduces network traffic and improve performance.
·         It can be used to help ensure the integrity of the database.

Question 245 – What are the Advantages of Stored Procedure in SQL Server?
·         Execution plan retention and reuse
·         Encapsulation of business rules and policies
·         Sharing of application logic between applications
·         Access to database objects that is both secure and uniform
·         Consistent, safe data modification
·         Network bandwidth conservation
·         Improved security
·         Reduced development cost and increased reliability
·         Centralized security, administration, and maintenance for common routines.
Question 246 – What are the DisAdvantages of Stored Procedure in SQL Server?
·         Source control can be a pain.
·         Debugging is hard.
·         Developing stored procedures can be a fairly specialized task, especially as they get more complex.

Question 247 – What is a User Defined Functions in SQL Server?
A user-defined function (UDF) is a prepared code segment that can accept parameters, process some logic, and then return some data. UDFs in SQL Server 2000 can accept anywhere from 0 to 1024 parameters

Question 248 – What is a Scalar value-returning User Defined Function in SQL Server?
·         Similar to functions in other languages.
·         Returns a single value of a scalar data type.
·         Can return user-defined data types.
·         Useful when the same segment of T-SQL code is used in several places
·         Can be used in several stored procedures and batch SQL statements.
·         Used to make the code more maintainable, reusable, and less complex.

Question 249 – What is an In Line Table User Defined Function in SQL Server?
·         Returns a row set of the SQL Server table data type.
·         Takes the structure of the row set from the SELECT statement itself.
·         It is an exceptional alternative to a view
·         Can pass parameters and in essence provide us with a parameterized, non-updateable view

Question 250 – What is a Multistatement Table User Defined Function in SQL Server?
·         Returns a table and is also an exceptional alternative to a view
·         Defines column names and data types in the RETURNS clause.
·         Able to house more complicated and numerous T-SQL logic blocks.

·         It can be used it in the FROM clause of a T-SQL command

No comments:

Post a Comment