Posts

Showing posts from October, 2016

Difference between array, arraylist, List, Hashtable, Dictionary and SortedList in c#

Basic difference is that arrays are of fixed size. Whereas an ArrayList implements the list data structure and can dynamically grow. While arrays would be more performance that a list, a list would be far more flexible since you don't need to know the required size initially. Array - represents an old-school memory array - kind of like a alias for a normal type[] array. Can enumerate. Can't grow automatically. I would assume very fast insertion, retrieve and speed. ArrayList - automatically growing array. Adds more overhead. Can enum., probably slower than a normal array but still pretty fast. These are used a lot in .NET List - one of my favorites - can be used with generics, so you can have a strongly typed array, e.g. List . Other than that, acts very much like ArrayList. Hashtable - plain old hashtable. O(1) to O(n) worst case. Can enumerate the value and keys properties, and do key/val pairs. Dictionary - same as above only strongly typed via generics, such a...

What are Scaffold templates in ASP.Net MVC?

Scaffolding in ASP.NET MVC is used to generate the Controllers,Model and Views for create, read, update, and delete CRUD functionality in an application. The scaffolding will be knowing the naming conventions used for models and controllers and views. Explain the types of Scaffoldings. Below are the types of scaffoldings : Empty Create Delete Details Edit List

What are AJAX Helpers in ASP.Net MVC?

AJAX Helpers are used to create AJAX enabled elements like as Ajax enabled forms and links which performs the request asynchronously and these are extension methods of AJAXHelper class which exists in namespace - System.Web.ASP.Net MVC. Below are the options in AJAX helpers : Url : This is the request URL. Confirm : This is used to specify the message which is to be displayed in confirm box. OnBegin : Javascript method name to be given here and this will be called before the AJAX request. OnComplete : Javascript method name to be given here and this will be called at the end of AJAX request. OnSuccess - Javascript method name to be given here and this will be called when AJAX request is successful. OnFailure - Javascript method name to be given here and this will be called when AJAX request is failed. UpdateTargetId : Target element which is populated from the action returning HTML

Explain Page Life Cycle in asp.net.

Following are the Page Life Cycle in asp.net. • InIt: Before constructing the control PreInIt then each control Instantiated set to Innitial state Added to Control State. • LoadViewState: Lost state of the controls restored from viewstate values. • Load: User Code runs, tests it's postback conditions to databind first value. • PostBack Data: Posted Data is passed to its associated controls. • PostBack Events: Events are fixed for controls in tree order, except the event that caused the post it's fired last. • Pre Render: Creat Child Controls, ensure contros are ready to render. • Save ViewState: Controls save current state (if different than innitital values) • Render: Each control Render itself to the Response. • Dispose: Page and all controls are destroyed.

Explain the methods used to render the views in ASP.Net MVC?

Below are the methods used to render the views from action - View() : To return the view from action. PartialView() : To return the partial view from action. RedirectToAction() : To Redirect to different action which can be in same controller or in different controller. Redirect() : Similar to "Response.Redirect()" in webforms, used to redirect to specified URL. RedirectToRoute() : Redirect to action from the specified URL but URL in the route table has been matched.

Explain the advantages of ASP.Net MVC over ASP.NET web form?

MVC Provides a clean separation of concerns among UI (Presentation layer), model (Transfer objects/Domain Objects/Entities) and Business Logic (Controller). Easy to UNIT Test in MVC. Improved reusability of model and views. We can have multiple views which can point to the same model and vice versa. Improved structuring of the code.

Difference between WCF and Web Services?

Below are the main differences between the WCF and Web Service:   Web Service : a.  Can be hosted in IIS only b.  Only two types of operations affects- One-Way, Request-Response c.  To serialize the data use System.Xml.Serialization d.  To encode the data use- XML 1.0, MTOM, DIME, Custom e. Web Service can be accessed through HTTP channel.   WCF service : a.  Can be hosted in IIS, Self Hosting, WAS, Windows Services etc b.  Three types of operations affects- One-Way, Request-Response and Duplex c.  To serialize the data use System.Runtimel.Serialization d.  To encode the data use- XML 1.0, MTOM,Binary, Custom e.  WCF Service can be accessed through HTTP, TCP, Named pipes, MSMQ,P2P etc.

Why to use UpdatePanel control in AJAX ASP.NET?

AJAX is a client side technology and it supports asynchronous communication between client and server. If the part of page need to be refreshed, then we can use this Update panel control, which uses AJAX request and does not harm the other part of the page. Using Update Panel improves the user experience of the page since it does not refresh the whole page.

What is the difference between cache object and session object?

Cache – This improves the performance by minimizing the database hits to fetch the data.  It instead stores the data in cache. So cache will be checked first for data and if it is not found then go to database to get the data. Session – Session will be created to store the details of the user for capturing the user’s specific actions. Session will be killed or it will be expired in 20 minutes.

Performance wise which is better, Session or ViewState?

For large amount of data, Session will be an efficient way to go. When session is not used, set it to null for memory overhead but this cannot be done in all the cases. Once the session timeout happened it automatically set to null. Default timeout is 20 minutes. In Viewstate, all data will be stored in HTML hidden fields. For large amount of data, it would give performance issues. Ideal size of viewstate should not be more than 20-30% of page size. So for less data viewstate will be an ideal solution.

Which are the different IIS isolation levels in ASP.NET?

IIS has three level of isolation – LOW (IIS process) - In this, ASP.NET application and main IIS process run in same process. So, if any application crashes it will adversely affect the others too. Medium (Pooled) - In Medium pooled scenario the IIS and web application run in different process. So in this case there will be two processes process1 and process2. Process1 runs the IIS process and Process2 runs the Web application. High (Isolated) - Here every process runs under it’s own process. This consumes heavy memory but has highest reliability.

Explain the components of web form in ASP.NET?

Server controls - The server controls are Hypertext Markup Language (HTML) elements that include a runat=server attribute. These controls provide automatic state management and server-side events and respond to the user events by executing event handler on the server. HTML controls - These controls also respond to the user events but the events processing happen on the client machine. Data controls - Data controls allows us to connect to the database, execute command and retrieve data from database.

What’s the difference between Literal control and Label control in Asp.Net?

Label control is rendered as when rendered as HTML. Label control styles like font size, font color etc can be changed with very less effort. Javascript or JQuery also can access the label control very easily. Literal control rendered as it is. Literal control cannot be styled easily like label control because it does not render in enclosed HTML tags. Javascript or Jquery will not be able to access literal control because while rendering it would not have ID in spite of giving the ID in mark up.

What is cross-page posting in asp.Net?

Server.Transfer() method is used for posting the data from one page to another. In cross page posting, data collected from different pages and will be displayed in single page. So, for doing this we need to set “ PostBackUrl ” property of the control, in which target page is specified and in target page we can use “ PreviousPage ” property. For doing this we need to set the directive - @PreviousPageType . Previous page control can be accessed from the method – “ FindControl() ”.

What is difference between Data list, Grid view and Repeater in asp.Net?

All these controls have many things in common like Data Source Property, Data Bind Method ItemDataBound and ItemCreated . When Data Source Property of a Grid view is assigned to a Dataset then each Data Row present in the Data Row Collection of Data Table is assigned to a corresponding DataGridItem and this is same for the rest of the two controls also. But The HTML code generated for a Grid view has an HTML TABLE element created for the particular Data Row and it’s a Table form representation with Columns and Rows. For a Data list it’s an Array of Rows and based on the Template Selected and the RepeatColumn Property value we can specify how many Data Source records should appear per HTML row. In short in Grid view we have one record per row, where as in data list we can have five or six rows per row.    In Repeater Control the data records which are to be displayed depends upon the Templates specified and the only HTML generated is the due to the Templates...

What is smart navigation in Asp.Net?

Using the Page.SmartNavigation property, we can enable smart navigation. When we set the property - Page.SmartNavigation to true, the following features are enabled for smart navigation. Scroll position of a Web page will be maintained after postback . Element which focus on a Web page is maintained during navigation. Most recent Web page state is only retained in the Web browser history folder. Flicker effect which could occur on a Web page during navigation will be minimized.

What is IIS? Why is it used?

Internet Information Services ( IIS ) is created by Microsoft to provide Internet-based services to ASP.NET Web applications. It makes your system to work as a Web server and provides the functionality to develop and deploy Web applications on the server. IIS handles the request-response cycle on the Web server. It offers the service of SMTP and front-page server extensions. As you know SMTP is used to send emails and use FrontPage server extensions to get the dynamic features of IIS , such as form handlers.

How many types of validation controls are provided by ASP.NET ?

There are FIVE types of validators in ASP.NET and they are – RequiredFieldValidator - It checks whether the control have any value or not. It is used, when you want the control not to be empty. RangeValidator - It checks, if the value in validated control is in that specific range. Eg: Range of Date Birth. CompareValidator - It checks that the value in controls should match the value in other control. Eg : Password and Retype Passwords. RegularExpressionValidator - When we want the control value that matches a specific regular expression. Eg : Checking for valid Email ID. CustomValidator - It is used to define User Defined validation.

What are the various ways of authentication techniques in ASP.NET?

There are basically three types of authentication modes in ASP.NET – Windows Authentication – windows authentication uses our system credentials for the authentication purpose.  Forms Authentication – This is a form based authentication. Login Control in ASP.NET supports this kind of authentication. Passport Authentication - Passport authentication lets you to use Microsoft’s passport service to authenticate users of your application.

What are the State Management options in ASP.NET ?

There are two types of state management in asp.net i.e Client-side state management and Server-side state management Client-side state management - This maintains information on the client’s machine using either of the following options – Cookies - Cookie is a small sized text file on the client machine either in the client’s file system or memory of client browser session. View State - Each page and control on the page has View State property. This allows automatic retention of page and control’s state between each trip to server. Query string - Query strings can maintain limited state information. Data has been passed from one page to another with the URL, but you can send limited size of data with the URL. Server-side state management - This mechanism retains state in the server. Below are the options to achieve it - Application State - The data stored in the application object can be shared by all the sessions of the application. Session State - Session State st...

What is Common Language Runtime or CLR

As part of Microsoft's .NET Framework, the Common Language Runtime ( CLR ) is programming that manages the execution of programs written in any of several supported languages , allowing them to share common object-oriented class es written in any of the languages . CLR handles the compilation and execution of .NET programs. CLR uses JIT(Just in time)  and compiles the IL code to machine code and then executes.  Below are the list of responsibilities of Common Language Run-time. Garbage Collection Code Verification Code Access Security Intermediate language -to-native translators and optimizer’s

What is the application event handlers in ASP.NET

Application event handlers are located in global.asax file of the asp.net application Below are the application event handlers in sequence of their execution - Application_Start - Fired when the first user visits a page of the application or first resource is requested from the server. A web application starts, when a browser requests a page of the application for the first time. The request will be received by the IIS which then starts ASP.NET worker process. The worker process then allocates a process space to the assembly and loads it. Application_End - Fired when there are no more users of the application. Application_BeginRequest - Fired at the beginning of each request to the server. Application_EndRequest - Fired at the end of each request to the server. Session_Start - Fired when any new user visits. Session_End - Fired when the users stop requesting pages and their session times out.

What is an HttpHandler and its use in ASP.NET

In the simplest terms, A handler is responsible for fulfilling requests from a browser. In ASP.NET HttpHandler is a class that implements the System.Web.IHttpHandler interface. ASP.NET HTTPHandlers are responsible for intercepting requests made to your ASP.NET web application server. They run as processes in response to a request made to the ASP.NET Site. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler. ASP.NET offers a few default HTTP handlers : Page Handler (.aspx): handles Web pages User Control Handler (.ascx): handles Web user control pages Web Service Handler (.asmx): handles Web service pages Trace Handler (trace.axd): handles trace functionality You can create your own custom HTTP handlers that render custom output to the browser. Typical scenarios for HTTP Handlers in ASP.NET are for example Delivery of dynamically created images (chart...