How can you handle UnManaged Code Exceptions in ASP.NET?
Which is the namespace used to write error message in event Lof File?
What are the Page level transaction and class level transaction?
What are different transaction options?
What is the namespace for encryption?
What is the difference between application and cache variables?
What is the difference between control and component?
You have defined one page_load event in ASPx page and same page_load event in code behind, how will program run?
Where would you use an IHttpModule, and what are the limitations of any approach you might take in implementing one?
Can you edit data in the Repeater control? Which template must you provide, in order to display data in Repeater control? How can you provide an alternating color scheme in a repeater control? What property must you set, and what method must you call in your code, in order to bind the data from some source to the repeater?
In what order do the events of an ASPX page executes. As a developer is it important to understand these events?
How would you get ASP.NET running in Apache web servers? Why would you even do this?
What tags do you need to add within the ASP:datagrid tags to bind columns manualy?
An ASP page is an HTML page that contains server-side scripts written on VBScript or Jscript or Perl that are processed by the Web server before being sent to the user’s browser. ASP can be combined with HTML, XML and COM to create Web sites.
Server-side scripts run when a browser requests an .asp file from the Web server. ASP is called by the Web server, which processes the requested file and executes script commands. It then formats a standard Web page and sends it to the browser.
Web Forms pages are built with ASP.NET technology. ASP.NET is built on the .NET Framework, so the entire framework is available to any ASP.NET application. Your applications can be written in any language compatible with the common language runtime, including Microsoft Visual Basic, Visual C#, and JScript .NET.
The ASP.NET page framework is a programming framework that runs on a Web server to dynamically produce and manage Web Forms pages.
Web Forms pages run on any browser or client device.
Cookie is a small amount of data and it contains page-specific information(usually user ID) the server sends to the client along with page output. Cookies can contain only strings.
5 What is ViewState? What does the “EnableViewState†property do? Whay would I want it on or off?
View state is a property of Web Forms page and each control of the page to save their values so it can be used between round trips to the server.
When the page is processed, the current state of the page and controls is inserted into a string and saved in the page as a hidden field. When the page is posted back to the server, the page parses the view state string at page initialization and restores property information in the page.
EnableViewState indicates whether the page maintains its view state, and the view state of any server controls it contains, when the current page request ends.
The benefits of using ViewState are it automatically store values between multiple requests for the same page, it is saved as a hidden field of the page and no server resources required.
It is better to disable ViewState if a control or a page contain large amount of data. Saving such an amount can affect the form load. Because the view state is stored in the page itself, storing large values can cause the page to slow down when users display it and when they post it.
The Global.asax file is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules and initializing global application objects. The Global.asax file resides in the root directory of an ASP.NET-based application.
You can debug .NET application using Visual Studio .NET.
If Visual Studio .NET is not installed you can use Systems.Diagnostics classes, Runtime Debugger (Cordbg.exe), or Microsoft Common Language Runtime Debugger (DbgCLR.exe)
System.Diagnostics includes the Trace and Debug classes for tracing execution flow, and the Process, EventLog, and PerformanceCounter classes for profiling code.
The Cordbg.exe command-line debugger can be used to debug managed code from the command-line interpreter.
DbgCLR.exe is a debugger with the Windows interface for debugging managed code.
To create ASP.NET Web applications, you use a standard deployment model: your project is compiled and the resulting files are deployed. The Web Forms code-behind class file (.aspx.vb, or .aspx.cs) is compiled into a project .dll file along with all other class files included in your project. This single project .dll file is then deployed to the server, without any source code. When a request for the page is received, the project .dll file is instantiated and executed.
ASP.NET, in conjunction with Microsoft Internet Information Services (IIS), can authenticate user credentials such as names and passwords using any of the following authentication methods:
• Windows: Basic, digest, or Integrated Windows Authentication. If the user making the request has already been authenticated in a Windows-based network, IIS can pass the user’s credentials through when requesting access to a resource.
• Microsoft Passport authentication
Passport authentication allows implementing single sign-in for multiple applications or websites that want to authenticate users. The user is expected to use only one username and password to access all the sites.
• Forms authentication
generally refers to a system in which unauthenticated requests are redirected to a registration form. The user provides credentials and submits the form. If the application authenticates the request, the system issues a cookie that contains the credentials or a key for reacquiring the identity.
• Client Certificate authentication
IIS supports the use of digital certificates and the secure sockets layer (SSL). In this scenario, either the server or the client has a certificate  a digital identification  that they have obtained from a third-party source. The certification is passed to your application with requests. It can be mapped to a Windows user account and granted appropriate permissions.
13 Explain different Authentication modes in ASP.NET?
Authentication modes are: Windows, Forms, Passport, or None.
ASP.NET uses Windows authentication in conjunction with IIS authentication. It authenticates the identity using basic, digest, or Integrated Windows authentication, or some combination of them.
All users are authenticated as soon as they log on to Windows.
Passport authentication is centralized authentication service provided by Microsoft that offers a single log on and core profile services for member sites.
Form authentication generally refers to a system in which unauthenticated requests are redirected to a registration form. The user provides credentials and submits the form. If the application authenticates the request, the system issues a cookie that contains the credentials or a key for reacquiring the identity.
None authentication is used when you want to apply anonymous authentication or a custom authentication scheme.
14 How.NET has implemented security for web applications?
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.
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
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.
19 How can you handle UnManaged Code Exceptions in ASP.NET?
Unmanaged code can include both C++-style SEH Exceptions and COM-based HRESULTS.
COM handles errors through HRESULT. If an exception occurs in unmanaged code, the COM HRESULT is mapped to the appropriate exception class, which is returned to .NET, where it can be handled like any other exception.
User-defined exception classes can specify whatever HRESULT is appropriate. These exception classes can dynamically change the HRESULT to be returned when the exception is generated by setting the HResult field on the exception object. Additional information about the exception is provided to the client through the IErrorInfo interface, which is implemented on the .NET object in the unmanaged process.
22 What are the Page level transaction and class level transaction?
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
{
}
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.
25 What is the difference between application and cache variables?
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.
26 What is the difference between control and component?
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.
28 Comments on .NET WebDev and Web services questions
24) Ans: System.Security.cryptography;
60.An XML document that references a DTD in a DOCTYPE statement
61.An XML document that does not reference a DTD(document type definition)
Source: http://www.epcedit.com/UserManual/g4701.html
1 How does ASP page work?
An ASP page is an HTML page that contains server-side scripts written on VBScript or Jscript or Perl that are processed by the Web server before being sent to the user’s browser. ASP can be combined with HTML, XML and COM to create Web sites.
Server-side scripts run when a browser requests an .asp file from the Web server. ASP is called by the Web server, which processes the requested file and executes script commands. It then formats a standard Web page and sends it to the browser.
2 How ASP.NET page works?
Web Forms pages are built with ASP.NET technology. ASP.NET is built on the .NET Framework, so the entire framework is available to any ASP.NET application. Your applications can be written in any language compatible with the common language runtime, including Microsoft Visual Basic, Visual C#, and JScript .NET.
The ASP.NET page framework is a programming framework that runs on a Web server to dynamically produce and manage Web Forms pages.
Web Forms pages run on any browser or client device.
3 What are the contents of cookie?
Cookie is a small amount of data and it contains page-specific information(usually user ID) the server sends to the client along with page output. Cookies can contain only strings.
4 How do you create a permanent cookie?
Dim oCookie As New HttpCookie(“permanentCookieâ€Â,â€ÂBonjour!â€Â)
oCookie.Expires=#12/01/2006#
Response.Cookies.Add(oCookie)
5 What is ViewState? What does the “EnableViewState†property do? Whay would I want it on or off?
View state is a property of Web Forms page and each control of the page to save their values so it can be used between round trips to the server.
When the page is processed, the current state of the page and controls is inserted into a string and saved in the page as a hidden field. When the page is posted back to the server, the page parses the view state string at page initialization and restores property information in the page.
EnableViewState indicates whether the page maintains its view state, and the view state of any server controls it contains, when the current page request ends.
The benefits of using ViewState are it automatically store values between multiple requests for the same page, it is saved as a hidden field of the page and no server resources required.
It is better to disable ViewState if a control or a page contain large amount of data. Saving such an amount can affect the form load. Because the view state is stored in the page itself, storing large values can cause the page to slow down when users display it and when they post it.
6 Give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?
In Application_Start you can initialize the variables, upload data from database table and store in ViewState or in Cache.
In Session_Start you can count the number of active sessions, automatically redirect users to the certain Web page at the beginning of the session.
7 Describe the role of global.asax?
The Global.asax file is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules and initializing global application objects. The Global.asax file resides in the root directory of an ASP.NET-based application.
8 How can you debug your.NET application?
You can debug .NET application using Visual Studio .NET.
If Visual Studio .NET is not installed you can use Systems.Diagnostics classes, Runtime Debugger (Cordbg.exe), or Microsoft Common Language Runtime Debugger (DbgCLR.exe)
System.Diagnostics includes the Trace and Debug classes for tracing execution flow, and the Process, EventLog, and PerformanceCounter classes for profiling code.
The Cordbg.exe command-line debugger can be used to debug managed code from the command-line interpreter.
DbgCLR.exe is a debugger with the Windows interface for debugging managed code.
9 How do you deploy your ASP.NET application?
To create ASP.NET Web applications, you use a standard deployment model: your project is compiled and the resulting files are deployed. The Web Forms code-behind class file (.aspx.vb, or .aspx.cs) is compiled into a project .dll file along with all other class files included in your project. This single project .dll file is then deployed to the server, without any source code. When a request for the page is received, the project .dll file is instantiated and executed.
10 Where do we store our connection string in ASP.NET application?
You can store Connection String in Web.config file:
create a new add key in the appSettings element.
Or in the Registry
add new subkeys to the SOFTWARE key in the HKEY_LOCAL_MACHINE
11 Explain security types in ASP.NET?
ASP.NET, in conjunction with Microsoft Internet Information Services (IIS), can authenticate user credentials such as names and passwords using any of the following authentication methods:
• Windows: Basic, digest, or Integrated Windows Authentication. If the user making the request has already been authenticated in a Windows-based network, IIS can pass the user’s credentials through when requesting access to a resource.
• Microsoft Passport authentication
Passport authentication allows implementing single sign-in for multiple applications or websites that want to authenticate users. The user is expected to use only one username and password to access all the sites.
• Forms authentication
generally refers to a system in which unauthenticated requests are redirected to a registration form. The user provides credentials and submits the form. If the application authenticates the request, the system issues a cookie that contains the credentials or a key for reacquiring the identity.
• Client Certificate authentication
IIS supports the use of digital certificates and the secure sockets layer (SSL). In this scenario, either the server or the client has a certificate  a digital identification  that they have obtained from a third-party source. The certification is passed to your application with requests. It can be mapped to a Windows user account and granted appropriate permissions.
13 Explain different Authentication modes in ASP.NET?
Authentication modes are: Windows, Forms, Passport, or None.
ASP.NET uses Windows authentication in conjunction with IIS authentication. It authenticates the identity using basic, digest, or Integrated Windows authentication, or some combination of them.
All users are authenticated as soon as they log on to Windows.
Passport authentication is centralized authentication service provided by Microsoft that offers a single log on and core profile services for member sites.
Form authentication generally refers to a system in which unauthenticated requests are redirected to a registration form. The user provides credentials and submits the form. If the application authenticates the request, the system issues a cookie that contains the credentials or a key for reacquiring the identity.
None authentication is used when you want to apply anonymous authentication or a custom authentication scheme.
14 How.NET has implemented security for web applications?
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.
15 How to do forms authentication in ASP.NET?
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
16 Explain authentication levels in.NET?
Authentication can be declared only at the machine, site, or application level.
17 Explain authorization levels in.NET?
Authorization controls client access to URL resources. It can be declared at any level: machine, site, application, subdirectory, or page.
18 How can you debug an ASP page, without touching the code?
You can debug ASP page using either the Microsoft Script Debugger or Visual InterDev
19 How can you handle Exceptions in ASP.NET?
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.
19 How can you handle UnManaged Code Exceptions in ASP.NET?
Unmanaged code can include both C++-style SEH Exceptions and COM-based HRESULTS.
COM handles errors through HRESULT. If an exception occurs in unmanaged code, the COM HRESULT is mapped to the appropriate exception class, which is returned to .NET, where it can be handled like any other exception.
User-defined exception classes can specify whatever HRESULT is appropriate. These exception classes can dynamically change the HRESULT to be returned when the exception is generated by setting the HResult field on the exception object. Additional information about the exception is provided to the client through the IErrorInfo interface, which is implemented on the .NET object in the unmanaged process.
21 Which is the namespace used to write error message in event Log File?
Namespace: System.Diagnostics
22 What are the Page level transaction and class level transaction?
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
{
}
23 What are different transaction options?
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.
24 What is the namespace for encryption?
System.Security.Cryptography
25 What is the difference between application and cache variables?
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.
26 What is the difference between control and component?
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.