dot net Interview questions -14

dot net Interview Questions -14

1. Where the viewstate is stored after the page postback?

ViewState is stored in a hidden field on the page at client side.  ViewState is transported to the client and back to the server, and is not stored on the server or any other external source.

2. Which validator control you use if you need to make sure the values in two different controls matched?

Compare Validator control.

3. What is caching?

Caching is a technique used to increase performance by keeping frequently accessed data or files in memory. The request for a cached file/data will be accessed from cache instead of actual location of that file.

4.How long the items in ViewState exists?

They exist for the life of the current page.

5.What are the different types of caching?

ASP.NET has 3 kinds of caching :
Output Caching,
Fragment Caching,
Data Caching.

6. What is ViewState?

ViewState is used to retain the state of server-side objects between page post backs.

7. Which type if caching will be used if we want to cache the portion of a page instead of whole page?

Fragment Caching: It caches the portion of the page generated by the request. For that, we can create user controls with the below code:

1<%@ OutputCache Duration="120" VaryByParam="CategoryID;SelectedID"%>

8. List the events in page life cycle.

1) Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
5) Page_Load
6) Page_LoadComplete
7) Page_PreRender
8)Render

9. Can we have a web application running without web.Config file?

Yes
 
10. What is Protected Configuration?

It is a feature used to secure connection string information.MailMessage and SmtpMail are classes defined System.Web.Mail namespace.

11. What are the different Session state management options available in ASP.NET?

    In-Process
    Out-of-Process.

In-Process stores the session in memory on the web server.Out-of-Process Session state management stores data in an external server.  The external server may be either a SQL Server or a State Server.  All objects stored in session are required to be serializable for Out-of-Process state management.

12. What is the good practice to implement validations in aspx page?

Client-side validation is the best way to validate data of a web page. It reduces the network traffic and saves server resources.

13. What are the event handlers that we can have in Global.asax file?

Application Events: Application_Start , Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed,  Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute,
Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache
Session Events: Session_Start,Session_End

14. Which protocol is used to call a Web service?

HTTP Protocol

15. Can we have multiple web config files for an asp.net application?

Yes.

16. What is the difference between web config and machine config?

Web config file is specific to a web application where as machine config is specific to a machine or server. There can be multiple web config files into an application where as we can have only one machine config file on a server.

17. What is Cross Page Posting?

When we click submit button on a web page, the page post the data to the same page. The technique in which we post the data to different pages is called Cross Page posting. This can be achieved by setting POSTBACKURL property of  the button that causes the postback. Findcontrol method of PreviousPage can be used to get the posted values on the page to which the page has been posted.

18.What is RedirectPermanent in ASP.Net?

RedirectPermanent Performs a permanent redirection from the requested URL to the specified URL. Once the redirection is done, it also returns 301 Moved Permanently responses.

19.What’s the use of Response.Output.Write()?

We can write formatted output  using Response.Output.Write().

20. In which event of page cycle is the ViewState available?
  
After the Init() and before the Page_Load().

21. What is the difference between Server.Transfer and Response.Redirect? 

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.

22. From which base class all Web Forms are inherited?

Page class.

23. What are the different validators in ASP.NET?

Required field Validator
Range  Validator
Compare Validator
Custom Validator
Regular expression Validator
Summary Validator

24.What is MVC?

MVC is a framework used to create web applications. The web application base builds on  Model-View-Controller pattern which separates the application logic from UI, and the input and events from the user will be controlled by the Controller.

25. What is ASP.Net?

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. Its successor of Microsoft Active Server Pages(ASP). Currently there is ASP.NET 4.0, which is used to develop web sites. There are various page extensions provided by Microsoft that are being used for web site development. Eg: aspx, asmx, ascx, ashx, cs, vb, html, xml etc.

26. Explain the working of passport authentication.

First of all it checks passport authentication cookie. If the cookie is not available then the application redirects the user to Passport Sign on page. Passport service authenticates the user details on sign on page and if valid then stores the authenticated cookie on client machine and then redirect the user to requested page

27. What are the advantages of Passport authentication?

All the websites can be accessed using single login credentials. So no need to remember login credentials for each web site.Users can maintain his/ her information in a single location.

28. What are the asp.net Security Controls?

    <asp:Login>: Provides a standard login capability that allows the users to enter their credentials

    <asp:LoginName>: Allows you to display the name of the logged-in user
    <asp:LoginStatus>: Displays whether the user is authenticated or not
    <asp:LoginView>: Provides various login views depending on the selected template
    <asp:PasswordRecovery>:  email the users their lost password

29.How do you register JavaScript for webcontrols ?

We can register javascript for controls using <CONTROL -name>Attribtues.Add(scriptname,scripttext) method.

30. How we can force all the validation controls to run?

The Page.Validate() method is used to force all the validation controls to run and to perform validation.

31. List all templates of the Repeater control.

ItemTemplate
AlternatingltemTemplate
SeparatorTemplate
HeaderTemplate
FooterTemplate

32.Which data type does the RangeValidator control support?

The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.

33. What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?

In HtmlInputCheckBoxcontrol, multiple item selection is possible whereas in HtmlInputRadioButton controls, we can select only single item from the group of items.

34. Which namespaces are necessary to create a localized application?

System.Globalization
System.Resources

35. List the major built-in objects in ASP.NET?

    Application
    Request
    Response
    Server
    Session
    Context
    Trace

36. In which event are the controls fully loaded?

Page load event.

37.what is boxing and unboxing?

Boxing is assigning a value type to reference type variable.Unboxing is reverse of boxing ie. Assigning reference type variable to value type variable.

38. Differentiate strong typing and weak typing

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.

39. What are the different types of cookies in ASP.NET?

Session Cookie – Resides on the client machine for a single session until the user does not log out.Persistent Cookie – Resides on a user’s machine for a period specified for its expiry, such as 10 days, one month, and never.

40. What is the file extension of web service?

Web services have file extension .asmx..

41. What are the components of ADO.NET?

The components of ADO.Net are Dataset, Data Reader, Data Adaptor, Command, connection.

42. What is the difference between ExecuteScalar and ExecuteNonQuery?

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.

43.What is IIS?

IIS Manager is a graphical interface for configuring your application pools or your Web, FTP, SMTP, or NNTP sites. With IIS Manager, you can configure IIS security, performance, and reliability features. You can add or delete sites; start, stop, and pause sites; back up and restore server configurations; and create virtual directories for better content management, to name only a few of the administrative capabilities. In previous releases of IIS, this tool was called the Internet Service Manager.
   
44.What is the full form of IIS?

Internet Information Server.
   
45.What is a Web service extension and how do I use the Web Service Extensions folder? (IIS 6.0)

The Web Service Extensions folder is the user interface for the new IIS 6.0 lockdown feature. This feature is a manifest of ISAPI extensions and CGIs with user-specified permissions, meaning, administrators must set the permissions to allow specific ISAPIs and CGIs to run on your server. Administrators can also specify the names of ISAPIs or CGIs that are forbidden to run on your server. Before loading an ISAPI extension .dll file or CGI .exe file, IIS checks this manifest for the permissions on the file. If the file is permitted to run, then the request proceeds normally. If the file is not permitted to run, then IIS returns a 404.2 error response to the client machine. The HTML page for a 404.2 error looks like a standard 404 error page, so the client machine processes the request as though the file did not exist. IIS logs the 404.2 error, which administrators can view to assess problems or potential threats against the server.
   
46.How do I publish documents or Web pages? (IIS 6.0)

1.Move your files to the \Inetpub\Wwwroot directory.
2.Type http://servername/filename in the address bar of your Internet browser to see your published files.
   
47.How do I create a virtual directory on a Web or FTP site? (IIS 6.0)

You can use IIS Manager to create virtual directories on your Web site.
   
48.How do I create a Web site?

When you install IIS on a computer running a member of the Windows Server 2003 family, a default Web site is set up for you. You can publish your content here immediately.
   
49.How do I create multiple Web sites?

To create multiple Web sites, you must first ensure that each site has unique identification. To accomplish this, you need to contact your network administrator to either obtain multiple IP addresses or to assign multiple host header names.
   
50.How do I stop and restart Internet services?

By using the "IISRESET" command
   
51.Can I change the name of my Web site and also redirect requests for the old site name to the new one?

You can configure your Web site to respond to both the old name and the new name, provided your network correctly routes both requests to your computer. This way, visitors can still reach your site by using the old name, and will be informed of the new name.
   
52.How can I confirm that a server certificate is attached to a Web site?

1.In IIS Manager, right-click the Web site, and click Properties.
2.Click the Directory Security tab.
3.Under Secure communications, if the View Certificate button is activated, there is a certificate attached to the Web site. If the button is not activated, you must attach a server certificate to the site to use the Secure Sockets Layer (SSL) features.
   
53.Can I attach more than one server certificate to a Web site?

No. Each Web site can have only one server certificate attached to it.
   
54.Can I attach the same server certificate to more than one site?

Yes. A server certificate can be attached to as many Web sites as needed.
   
55.Can I attach a server certificate to an FTP site?

No. FTP sites do not support Secure Sockets Layer (SSL) features.
   
56.Should I create a backup copy of my server certificate?

Yes. Your server certificate is a valuable investment, and is the key to your server's Secure Sockets Layer features. To create a backup copy of your server certificate, copy the entire certificate on to a floppy disk and store it in a safe place.
   
57.Does ASP debugging work in IIS 6.0 worker process isolation mode?

Yes, when you configure Launch and Access permissions to enable ASP debugging in worker process isolation mode for Script Debugger and Visual InterDev.

58.What is the difference between RegisterClientScriptBlock and RegisterStartupScript?

RegisterClientScriptBlock emits the JavaScript just after the opening tag. RegisterStartupScript emits the JavaScript at the bottom of the ASP.NET page just before the closing tag
   
59.How do you submit a form using JavaScript?

Use document.forms[0].submit() (0 refers to the index of the form – if we have more than one form in a page, then the first one has the index 0, second has index 1 and so on).
   
60.How to read and write a file using JavaScript?

I/O operations like reading or writing a file is not possible with client-side JavaScript.
   
61.What are JavaScript Data Types?

JavaScript Data Types are Number, String, Boolean, Function, Object, Null, Undefined
   
62.How to create arrays in JavaScript?

We can declare an array like this
var scripts = new Array()
We can add elements to this array like this
scripts[0] = "First"
scripts[1] = "Second"
scripts[2] = "third"
scripts[3] = "Fourth"
Now our array scripts have 4 elements inside it and we can print or access them by using their index number. Note that index number starts from 0. To get the third element of the array we have to use the index number 2. Here is the way to get the third element of an array.
document.write(scripts[2])
We also can create an array like this
var no_array = new Array(21, 22, 23, 24, 25)
   
63.Difference between JavaScript and Java?

JavaScript was developed by Brendan Eich of Netscape. Java was developed at Sun Microsystems. While the two languages share some common syntax, they were developed independently of each other and for different audiences. Java is a full-fledged programming language tailored for network computing it includes hundreds of its own objects, including objects for creating user interfaces that appear in Java applets (in Web browsers) or standalone Java applications. In contrast, JavaScript relies on whatever environment it's operating in for the user interface, such as a Web document's form elements. JavaScript was initially called LiveScript at Netscape while it was under development. A licensing deal between Netscape and Sun at the last minute let Netscape plug the "Java" name into the name of its scripting language. Programmers use entirely different tools for Java and JavaScript. It is also not uncommon for a programmer of one language to be ignorant of the other. The two languages don't rely on each other and are intended for different purposes. In some ways, the "Java" name on JavaScript has confused the world's understanding of the differences between the two. On the other hand, JavaScript is much easier to learn than Java and can offer a gentle introduction for newcomers who want to graduate to Java and the kinds of applications you can develop with it
   
64.What is the difference between the Methods GET and POST in HTML forms?

GET: Parameters are passed in the query string. Maximum amount of data that can be sent via the GET method is limited to about 2kb. POST: Parameters are passed in the request body. There is no limit to the amount of data that can be transferred using POST. However, there are limits on the maximum amount of data that can be transferred in one name/value pair.
   
65.How to write a script for "Select" lists using JavaScript?

1. To remove an item from a list set it to null mySelectObject.options[3] = null.
2. To truncate a list set its length to the maximum size you desire mySelectObject.length = ?.
3. To delete all options in a select object set the length to 0. mySelectObject.leng=0.
   
66.Is a JavaScript script faster than an ASP script?

Yes. Since JavaScript is a client-side script it does require the web server's help for its computation, so it is always faster than any server-side script like ASP, PHP, etc..
   
67.What Boolean operators does JavaScript support?

Boolean operators in JavaScript are as under &&, || and !
   
68.What are the ways to emit client-side JavaScript from server-side code in ASP. NET?

The Page object in ASP. NET has two methods that allow emitting of client-side JavaScript: RegisterClientScriptBlock and RegisterStartupScript. Example usage:
Page.RegisterClientScriptBlock("ScriptKey", "<script language="javascript;">" + "function TestFn() { alert('Clients-side JavaScript'); }</script>"); Page.RegisterStartupScript("ScriptKey", "<script language="javascript">" + "function TestFn() { alert('Clients-side JavaScript'); }</script>");.
ScriptKey is used to suppress the same JavaScript from being emitted more than once. Multiple calls to RegisterClientScriptBlock or RegisterStartupScript with the same value of ScriptKey emit the script only once, on the first call.
   
69.What is the difference between RegisterClientScriptBlock and RegisterStartupScript?

RegisterClientScriptBlock emits the JavaScript just after the opening tag. RegisterStartupScript emits the JavaScript at the bottom of the ASP. NET page just before the closing tag.
   
70.How to get the contents of an input (text) box using JavaScript?

Use the "value" property. var myValue = window.document.getElementById("MyTextBox").value;
   
71.How to determine the state of a checkbox using JavaScript?

Determining the state of a checkbox in JavaScript var checkedP = window.document.getElementById("myCheckBox").checked;
   
72.What is the difference between an alert box and a confirmation box?

An alert box displays only one button which is the OK button whereas the Confirm box displays two buttons namely OK and cancel.
   
73.What is a prompt box?

A prompt box allows the user to enter input by providing a text box.
   
74.What looping structures are there in JavaScript?

JavaScript supports the for loop, while loop, do-while loop, but there is no foreach loop in JavaScript.
   
75.To put a "close window" link on a page?

<a href='javascript:window.close()' class='anyCSSClass'> Close </a>
   
76.How to hide JavaScript code from old browsers that don't run it?

Use the below specified style of comments <script language=javascript> <!-- javascript code goes here // --> or Use the <NOSCRIPT>some html code </NOSCRIPT> tags and code the display html statements between these and this will appear on the page if the browser does not support JavaScript
   
77.What does JavaScript null mean?

The null value is a unique value representing no value or no object. It implies no object, or null string, no valid Boolean value, no number and no array object.
   
78.How do you assign object properties?

obj["age"] = 17; //or obj.age = 17;
   
79.What is this keyword?

In JavaScript this keywork refers to the current object.
   
80.To set all checkboxes to true using JavaScript?

//select all input tags function SelectAll() { var checkboxes = document.getElementsByTagName("input"); for(i=0;i<checkboxes.length;i++) { if(checkboxes.item(i).attributes["type"].value == "checkbox") { checkboxes.item(i).checked = true; } } }
   
81.What is the difference between undefined value and null value?

(i) Undefined value cannot be explicitly stated that is there is no keyword called undefined whereas null value has keyword called null (ii) typeof undefined variable or property returns undefined whereas typeof null value returns object
   
82. How will you differentiate a submaster page from a top-level master page?

Similar to a content page, a submaster page also does not have complete HTML source code; whereas, a top-level master page has complete HTML source code inside its source file.

83. What are Web server controls in ASP.NET?

The ASP.NET Web server controls are objects on the ASP.NET pages that run when the Web page is requested. Many Web server controls, such as button and text box, are similar to the HTML controls. In addition to the HTML controls, there are many controls, which include complex behavior, such as the controls used to connect to data sources and display data.

84. What is the difference between a HyperLink control and a LinkButton control?

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

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

There are various techniques in ASP.NET to authenticate a user. You can use one of the following ways of authentication to select a built-in authentication provider:

Windows Authentication - This mode works as the default authentication technique. It can work with any form of Microsoft Internet Information Services (IIS) authentication, such as Basic, Integrated Windows authentication (NTLM/Kerberos), Digest, and certificates. The syntax of Windows authentication mode is given as follows: <authentication mode="windows" />
Forms Authentication - You can specify this mode as a default authentication mode by using the following code snippet: <authentication mode="Forms"/>
Passport - This mode works with Microsoft Passport authentication, as shown in the following code snippet: <authentication mode = "Passport"/>

86. What are the different ways to send data across pages in ASP.NET?

The following two ways are used to send data across pages in ASP.NET:
Session
Public properties

87. What does the WebpartListUserControlPath property of a DeclarativeCatalogPart control do?

The WebpartListUserControlPath property sets the route of the user defined control to aDeclarativeCatalogPart control.

88. What do you mean by the Web Part controls in ASP.NET?

The Web Part controls are the integrated controls, which are used to create a Web site. These controls allow the users to change the content, outlook, and state of Web pages in a Web browser.

89. What type of the CatalogPart control enables users to restore the Web Parts that have been removed earlier by the user?

The PageCatalogPart control.

90. What is the use of web.config? What is the difference between machine.config and web.config?

ASP.NET configuration files are XML-based text files for application-level settings and are saved with the name web.config. These files are present in multiple directories on an ASP.NET Web application server. Theweb.config file sets the configuration settings to the directory it is placed in and to all the virtual sub folders under it. The settings in sub directories can optionally override or change the settings specified in the base directory.

The difference between the web.config and machine.config files is given as follows:
<WinDir>\Microsoft.NET\Framework\<version>\config\machine.config provides default configuration settings for the entire machine. ASP.NET configures IIS to prohibit the browser directly from accessing the web.config files to make sure that their values cannot be public. Attempts to access those files cause ASP.NET to return the 403: Access Forbidden error.
ASP.NET uses these web.config configuration files at runtime to compute hierarchically a sole collection of settings for every URL target request. These settings compute only once and cached across further requests. ASP.NET automatically checks for changing file settings and do not validate the cache if any of the configuration changes made.

91. Explain the concept of states in ASP.NET.

State is quite an innovative concept in Web development because it eliminates the drawback of losing state data due to reloading of a Web page. By using states in a Web application, you can preserve the state of the application either at the server or client end. The state of a Web application helps you to store the runtime changes that have been made to the Web application. For example, as already described earlier, a change in the data source of the Web application might be initiated by a user when he/she selects and saves some products in the shopping cart.
If you are not using states, these changes are discarded and are not saved. You may think that the whole concept of storing states is optional. However, under certain circumstances, using states with applications is imperative. For example, it is necessary to store states for Web applications, such as an e-commerce shopping site or an Intranet site of a company, to keep track of the requests of the users for the items they have selected on the shopping site or the days requested for vacation on the Intranet site.

92. Can we validate a DropDownList by RequiredFieldValidator?

Yes, we can validate a DropDownList by RequiredFieldValidator. To perform this validation, we have to set the InitialValue property of RequiredFieldValidator control.

93. List the features of the Chart control.

The following are the features of the Chart control:

Bounds a chart with any data source.
Simple manipulation of chart data, such as copying, merging, grouping, sorting, searching, and filtering.
Support many statistical and financial formulas for data analysis.
Provide advanced chart outlook, such as 2-D, 3-D, lighting, and perspective.
Support events and customizations.
Includes interactivity with Microsoft AJAX.
Supports AJAX Content Delivery Network (CDN).

94. Which class is inherited when an ASP.NET server control is added to a Web form?

The System.Web.UI.WebControls class is inherited when an ASP.NET server control is added to a Web form.

95. What events are fired when a page loads?

The following events fire when a page loads:

Init() - Fires when the page is initializing.
LoadViewState() - Fires when the view state is loading.
LoadPostData() - Fires when the postback data is processing.
Load() - Fires when the page is loading.
PreRender() - Fires at the brief moment before the page is displayed to the user as HTML.
Unload() - Fires when the page is destroying the instances of server controls.

96. Write three common properties of all validation controls.

Three common properties of validation controls are as follows:
ControlToValidate - Provides a control to validate
ErrorMessage - Displays an error message
IsValid - Specifies if the control's validation has succeeded or not
Text - Displays a text for validation control before validation

97. What are navigation controls? How many navigation controls are there in ASP.NET 4.0?

Navigation controls help you to navigate in a Web application easily. These controls store all the links in a hierarchical or drop-down structure; thereby facilitating easy navigation in a Web application.
There are three navigation controls in ASP.Net 4.0.
SiteMapPath
Menu
TreeView

98. What happens if an ASP.NET server control with event-handling routines is missing from its definition?

The compilation of the application fails.

99. What are server-side comments?

Server-side comments are included in an ASP.NET page for the purpose of documentations as shown in the following code snippet:
<%--This is an example of server-side comments --%>
The server-side comments begin with <%-- and end with --%>.

100. How can we provide the WebParts control functionality to a server control?

We can provide the WebParts controls functionality to a server control by setting the CreateWebPart property of WebPartManger.

101. Which ASP.NET configuration options are supported in the ASP.NET implementation on the shared Web hosting platform?

There are many ASP.NET configuration choices, which are not able to configure at the site, application, or child directory level on the shared hosting environment. Some options can produce security, performance, and stability problem to the server and therefore cannot be changed.
The following settings are the only ones that can be changed in the web.config file(s) of your Web site:
   i.browserCaps
   ii. clientTarget
   iii.pages
   iv.customErrors
   v.globalization
   vi.authorization
   vii.authentication
   viii.webControls
   ix.webServices

102. How do you prevent a validation control from validating data at the client end?

You can prohibit a validation control to validate data at the client side by setting the EnableClientScriptproperty to False.

103. What is cross-page posting in ASP.NET?

The Server.Transfer() method is used to post data from one page to another. In this case, the URL remains the same. However, in cross page posting, data is collected from different Web pages and is displayed on a single page. To do so, you need to set the PostBackUrl property of the control, which specifies the target page. In the target page, you can access the PreviousPage property. For this, you need to use the@PreviousPageType directive. You can access the controls of previous page by using the FindControl()method.

0 comments:

Post a Comment