.NET Web Development and Services Interview Questions and Answers

Started by Kalyan, Aug 18, 2008, 12:19 PM

Previous topic - Next topic

Kalyan

.NET Web Development and Services Interview Questions and Answers

1.How.NET has implemented security for web applications?

Ans.To secure Web application, .NET uses two functions: Authentication and Authorization.

Authentication is the process of obtaining identification credentials such as name and password from a user and validating those credentials against some authority.

Authorization limits access rights by granting or denying specific permissions to an authenticated identity.


2.How to do forms authentication in ASP.NET?

Ans.You need to create an entry in Web.Config

authentication mode="Forms"

forms

name=".TheCookie"

loginUrl="/login/login.aspx"

protection="All"

timeout="70″

path="/"/

/authentication


3.Explain authentication levels in.NET?

Ans.Authentication can be declared only at the machine, site, or application level.


4.Explain authorization levels in.NET?

Ans.Authorization controls client access to URL resources. It can be declared at any level: machine, site, application, subdirectory, or page.


5.How can you debug an ASP page, without touching the code?

Ans.You can debug ASP page using either the Microsoft Script Debugger or Visual InterDev


6.How can you handle Exceptions in ASP.NET?

Ans.You can handle Exceptions using Try Catch Finally block.

Also in Global.asax you can create an application-wide error handler Application_Error or create a handler in a page for the Page_Error event. Application_Error and Page_Error methods are called if an unhandled exception occurs anywhere in your page or application.

You can also use the Page class property ErrorPage that gets or sets the error page to which the requesting browser is redirected in the event of an unhandled page exception.

It works only when customErrors mode is on in Web.Config or Machine.Config.

The sub-element error of customErrors element in Web.Config can be used to define one custom error redirect associated with an HTTP status code and

defaultRedirect attribute is used to specify the default URL to direct a browser to if an error occurs. When defaultRedirect is not specified, a generic error is displayed instead.


7.Which is the namespace used to write error message in event Lof File?

Ans.Namespace: System.Diagnostics


8.What are the Page level transaction and class level transaction?

Ans.ASP.NET transaction support allows pages to participate in ongoing Microsoft .NET Framework transactions. Transaction support is exposed via an @Transaction directive that indicates the desired level of support: Required, RequiresNew, Supported, NotSupported, Disabled.

The Transaction attribute is applied at the class level too to indicate that all class methods should be run in the context of a transaction. If an unhandled exception is thrown during the execution of a class method, the transaction is aborted. Otherwise, the transaction is committed.

using System.EnterpriseServices;

[transaction]

public class TransactionAttribute_Cl : ServicedComponent

{

}


9.What are different transaction options?

Ans.Required - Shares a transaction, if one exists, and creates a new transaction, if necessary.

RequiresNew- Creates the component with a new transaction, regardless of the state of the current context.

Supported- Shares a transaction, if one exists.

NotSupported- Indicates that the object does not run within the scope of transactions. When a request is processed, its object context is created without a transaction, regardless of whether there is a transaction active.

Disabled - Ignores any transaction in the current context.


10.What is the namespace for encryption?

Ans.System.Security.cryptography;


11.What is the difference between application and cache variables?

Ans.ASP.NET allows you to save values using application state (an instance of the HttpApplicationState class) for each active Web application. Application state is a global storage mechanism accessible from all pages in the Web application and is thus useful for storing information that needs to be maintained between server round trips and between pages.

The memory occupied by variables stored in application state is not released until the value is either removed or replaced.

Application state is a key-value dictionary structure created during each request to a specific URL. You can add your application-specific information to this structure to store it between page requests.

Once you add your application-specific information to application state, the server manages it.

Cache data can persist for a long time, but not across application restarts. It can hold both large and small amounts of data effectively. Also, data can expire based on time set by the application code or other dependencies; this feature is not available in the Application object.


12.What is the difference between control and component?

Ans.Components implement the System.ComponentModel.IComponent interface by deriving from the SystemComponent.Model.Component base class. Component is generally used for an object that is reusable and can interact with other objects. A .NET Framework component additionally provides features such as control over external resources and design-time support.

A control is a component that provides user-interface capabilities. Controls draw themselves and shown in the visual area.

The .NET Framework provides two base classes for controls: one for client-side Windows Forms controls and the other for ASP.NET server controls. These are System.Windows.Forms.Control and System.Web.UI.Control. System.Windows.Forms.Control derives from Component base class and itself provides UI capabilities.

System.Web.UI.Control implements IComponent and provides the infrastructure on which it is easy to add UI functionality.


13.What is validXML document?

Ans.An XML document that references a DTD in a DOCTYPE statement



14.What is well formedXML document?

Ans.An XML document that does not reference a DTD(document type definition)