This Scripting for google anayltics

ASP Dot Net Interview Questions and Answers for Freshers, Experienced

It is a framework developed by Microsoft on which we can develop new generation web sites using web forms(aspx), MVC, HTML, Javascript, CSS etc. The ASP.NET compiles the Web pages and provides much better performance than scripting languages, such as Javascript. The Web Forms support to create powerful forms-based Web pages. You can use ASP.NET Web server controls to create interactive Web applications. With the help of Web server controls, you can easily create a Web application.Currently there is ASP.NET 4.5, which is used to develop web sites.

  • 1. ASP is interpreted, ASP.NET is compiled.
  • 2. ASP :- Error handling is very poor. ASP.NET :- Error handling is very good.
  • 3. ASP has Mixed HTML and coding logic where in html and coding part are separated by code behind files.
  • 4. Classic ASP uses a technology called ADO to connect and work with databases. ASP.NET uses the ADO.NET technology
  • 5. ASP.NET purely object oriented whereas ASP is partially object oriented.
  • 6. For ASP No in-built support for XML whereas in ASP.NET full XML Support for easy data exchange.

Common Language Runtime (CLR) is a managed execution environment that is part of Microsoft’s .NET framework. CLR manages the execution of programs written in different supported languages.

Common Language Runtime (CLR) is a heart of Microsoft’s .NET framework.

CLR transforms source code into a form of bytecode known as Common Intermediate Language (CIL). At run time, CLR handles the execution of the CIL code.

Below are the list of responsibilities of Common Language Runtime –
  • • Garbage Collection
  • • Code Access Security
  • • Code Verification

The Common Type System (CTS) is a standard for defining and using data types in the .NETframework. CTS defines a collection of data types, which are used and managed by the run time to facilitate cross-language integration.

The common type system supports two general categories of types:-
  • • Value types(Int,char,decimal,double,float,long)
  • • Reference types(String,All arrays,Delegates)
Note:- CTS is a base class library that contains all type information like Int32, Int64, String , Boolean etc.

The CLS is a subset of the common type system.CLS just a documentation that map base type into different - 2 language datatype, compiler reads and converts language datatype to documented base type (i.e CTS type) e.g compiler reads the associated base type of int(C# Integer in VB) is Int32 from CLS guidelines and convert it to Int32.

In Simple words CLS is a set of rules which is defined by .Net Framework.

Response.Output.Write() gives you String.Format-style formatted output and the Response.Write() doesn't.

For Example :-
Response.Write("Current Date Time is "+DateTime.Now.ToString());
Response.Output.Write("{0} is {1:d}", "Current Date Time is: ",DateTime.Now);
  • • In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. The clients url history list or current url Server does not update in case of Server.Transfer.
  • • Response.Redirect is used to redirect the user’s browser to another page or site. It performs trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.
Following are the Web Form Events in the sequence of their execution -
  • 1) Page_PreInit
  • 2) Page_Init
  • 3) Page_InitComplete
  • 4) Page_PreLoad
  • 5) Page_Load
  • 6) Page_LoadComplete
  • 7) Page_PreRender
  • 8) Render
Below are the event handlers in sequence of their execution -
  • 1) Application_Start - Fired when the first user visits a page of the application or first resource is requested from the server.
  • 2) Application_End - Fired when there are no more users of the application.
  • 3) Application_BeginRequest - Fired at the beginning of each request to the server.
  • 4) Application_EndRequest - Fired at the end of each request to the server.
  • 5) Session_Start - Fired when any new user visits.
  • 6) Session_End - Fired when the users stop requesting pages and their session times out.
  • 1) Required field Validator
  • 2) Range Validator
  • 3) Compare Validator
  • 4) Custom Validator
  • 5) Regular expression Validator
  • 6) Summary Validator

View state is a great idea to store information in a page, It ViewState indicates the status of the page when submitted to the server. The retention of state is called the view state and is stored within a hidden control on the page. When an ASP.NET page is submitted to the server, the state of the controls is encoded and sent to the server at every form submission in a hidden field known as __VIEWSTATE.

                                    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/sjdljdlksdkhksbcklkdgjlakdkdjhffkkfjflld=" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="EF+OtTrCyyoqHUfLBealA" />

A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values. The default time for a Cookie to expire is 30 minutes.

Type of Cookies ?
  • 1. Persist Cookie - A cookie has not have expired time Which is called as Persist Cookie
  • 2. Non-Persist Cookie - A cookie has expired time Which is called as Non-Persist Cookie

Here is a some list of properties containing the HttpCookies Class:-

  • 1. Domain: Using these properties we can set the domain of the cookie.
  • 2. Expires: This property sets the Expiration time of the cookies.
  • 3. HasKeys: If the cookies have a subkey then it returns True.
  • 4. Name: Contains the name of the Key.
  • 5. Path: Contains the Virtual Path to be submitted with the Cookies.
  • 6. Secured: If the cookies are to be passed in a secure connection then it only returns True.
  • 7. Value: Contains the value of the cookies.

The FormsAuthentication.Signout() method is used to sign out from the forms authentication.

There will be a roundtrip of the page between client and a server in request-response model, so this mechanism is called Post Back.

if (!IsPostBack)
// generate form;

If you want a control to postback automatically when an event is raised, you need to set the AutoPostBackproperty of the control to True.

AutoPostBack = true permits control to post back to the server. It is associated with an Event.

                                    <asp:DropDownList id="id" runat="server" AutoPostBack="true" OnSelectIndexChanged="..." />

We can SetNoStore on HttpCachePolicy object exposed by the Response object’s Cache property:-

  • Response.Cache.SetNoStore ();
  • Response.Write (DateTime.Now.ToLongTimeString ());
  • Role Based Security used to implement security based on roles assigned to user groups in the organization.
  • Then we can allow or deny users based on their role in the organization. Windows defines several built-in groups, including Administrators, Users, and Guests.
< authorization >
< allow roles="Domain_Name\Administrators" / >   < !-- Allow Administrators in domain. -- >
< deny users="*"  / >                            < !-- Deny anyone else. -- >
< /authorization >

Login controls encapsulate all the features offered by Forms authentication. Login controls internally use Forms Authentication class to implement security, by prompting for user credentials validating them.

  • • In strong typing, the data types of variable are checked at compile time.
  • • On the other hand, in case of weak typing the variable data types are checked at runtime.
  • • In case of strong typing, there is no chance of compilation error.
  • • Scripts use weak typing and hence issues arises at runtime.

The Query String helps in sending the page information to the server.

  • 1. ItemTemplate
  • 2. AlternatingltemTemplate
  • 3. SeparatorTemplate
  • 4. HeaderTemplate
  • 5. FooterTemplate
  • • ExecuteScalar returns output value where as ExecuteNonQuery does not return any value but the number of rows affected by the query.
  • • ExecuteScalar used for fetching a single value and ExecuteNonQuery used to execute Insert and Update statements.

A HyperLink control does not have the Click and Command events while the LinkButton control has them, which can be handled in the code-behind file of the Web page.

It executes application-level events and sets application-level variables.

  • • Serialization is the process of converting an object into a stream of bytes.
  • • Deserialization is the process of creating an object from a stream of bytes.
Both these processes are usually used to transport objects.

MSIL is the Microsoft Intermediate Language. All .Net languages' executable exists as MSIL which gets converted into machine specific language using JIT compiler just before execution.

Master Page acts like a normal page. Master Pages can contain controls, code or markup as in web form. Master page will have a control called "ContentPlaceHolder", which defines region of master page which renders HTML content of child pages which uses master page. Master pages will have extension ".master" and there will be a master directive at the top of the page as shown below -

App_Code folder is part of ASP.NET folders. It stores any type of objects like text files, classes or reports. Advantage of App_Code folder is that if multiple classes or objects been added into this folder it creates a single dll for all.

GridView : -
  • • Limited in design, works like an html table. More in built functionality like edit/update, page, sort. Lots of overhead
  • • A GridView displays your data source in an HTML table and extends it to allow paging, sorting, editing etc.
  • • A gridview can only show your data in a table.
  • • Editing of contents is supported.
  • • Built-in Paging and Sorting is provided.
  • • Performance is very slow as compared to Repeater.
Repeater : -
  • • Very light weight. No built in functionality like Headers, Footers. Has the least overhead.
  • • A repeater is a template control, where you specify the html that is used to render each row.
  • • A repeater can show your data in any way you want by creating the relevant ItemTemplate. For example you might show a list of products, with each product having an image, description, list of colours, price etc, all arranged as you'd normal see a product listing. A repeater can supply that kind of display flexibility.
  • • Editing of contents is not supported.
  • • You need to write custom code.
  • • This is very light weight and fast data control among all the data control

This property is used to enable the ViewState property on the page. It is set to ON, to allow it to save the input values of the user between postback requests. When is set to OFF, it won't allow to save the user input in postbacks.

                                     <asp:Label ID="ErrorMessageLabel" EnableViewState="true" runat="server" />
                                    <asp:Label ID="Label1" EnableViewState="false" runat="server" />

Reflection is a mechanism through which types defined in the metadata of each module can be accessed. The System.Reflection namespace will have the classes that can be used to define the types for an assembly.

  • • Once the web application is deployed into IIS, we can set the Application Pool to the website directory where web application hosted/deployed.
  • • Application Pool is assigned to the website to make it secure and confidential.
  • • Multiple websites can be assigned under a single application pool which in turn will be under a single worker process.

AutoEventWireup is used for wiring up the events in page so that it can be given at the page level. Value of this attribute is Boolean (true or false).

By default it is set to "true" for C# web form where as, it is "false" for VB.NET web forms.

GridView Events are as below –
  • 1. PageIndexChanging :- This event will be fired when pager button is clicked and before Gridview control handles this operation.
  • 2. PageIndexChanged :- This event will be fired when pager button is clicked and after Gridview control handles this operation.
  • 3. RowCommand :- This event will be fired when any button is clicked in Gridview.
  • 4. RowDataBound :- This event will be fired when data is bounded to GridView.
  • 5. RowCreated :- This event will be fired when row is created in GridView.
  • 6. RowDeleted :- This event will be fired when row is deleted in GridView.

There are six objects are there in ASP.NET and they are following :-

  • • Session
  • • Request
  • • Response
  • • Object Request
  • • Server
  • • Application

HTML elements are treated as text by default. Once we add "runat=server" attribute to HTML element, it will be treated as a server control. If we add "runat=server" attribute we have to make sure this element is in

<form> tag because it indicates that form is processed by server.

The Label control's final html code has an HTML tag; whereas, the Literal control's final html code contains only text, which is not surrounded by any HTML tag.

Basically timeout of session is 20 minutes and if we want to change this timeout we can do in following way –
  • • Change the Session time out in web.config. (In sessionstate tag change the timeout)
  • • Change the Session time out in code using timeout property of session class.

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.

Who Should Read TechTrick?

All the tricks and tips that TechTrick provides only for educational purpose. If you choose to use the information in TechTrick to break into computer systems maliciously and without authorization, you are on your own. Neither I (TechTrick Admin) nor anyone else associated with TechTrick shall be liable. We are not responsibe for any issues that caused due to informations provided here. So, Try yourself and see the results. You are not losing anything by trying... We are humans, Mistakes are quite natural. Here on TechTrick also have many mistakes..