Friday, April 3, 2009

ASP.NET Application and Security Interview Questions Part II

11. How can u handle Exceptions in Asp.Net?

12. How can u handle Un Managed Code Exceptions in ASP.Net?

13. Asp.net - How to find last error which occurred?

Ans. A: Server.GetLastError();
[C#]
Exception LastError;
String ErrMessage;
LastError = Server.GetLastError();
if (LastError != null)
ErrMessage = LastError.Message;
else
ErrMessage = "No Errors";
Response.Write("Last Error = " + ErrMessage);

14. How to do Caching in ASP?

Ans. A: <%@ OutputCache Duration="60" VaryByParam="None" %>

VaryByParam value Description
none One version of page cached (only raw GET)
* n versions of page cached based on query string and/or POST body
v1 n versions of page cached based on value of v1 variable in query string or POST body
v1;v2 n versions of page cached based on value of v1 and v2 variables in query string or POST body

15. <%@ OutputCache Duration="60" VaryByParam="none" %>
<%@ OutputCache Duration="60" VaryByParam="*" %>
<%@ OutputCache Duration="60" VaryByParam="name;age" %>
The OutputCache directive supports several other cache varying options
· VaryByHeader - maintain separate cache entry for header string changes (UserAgent, UserLanguage, etc.)
· VaryByControl - for user controls, maintain separate cache entry for properties of a user control
· VaryByCustom - can specify separate cache entries for browser types and version or provide a custom GetVaryByCustomString method in HttpApplicationderived class

16. What is the Global ASA(X) File?

17. Any alternative to avoid name collisions other then Namespaces.

Ans. A scenario that two namespaces named N1 and N2 are there both having the same class say A. now in another class i ve written
using N1;using N2;
and i am instantiating class A in this class. Then how will u avoid name collisions?
Ans: using alias
Eg: using MyAlias = MyCompany.Proj.Nested;

18. Which is the namespace used to write error message in event Log File?

19. What are the page level transaction and class level transaction?

20. What are different transaction options?

21. What is the namespace for encryption?

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

23. What is the difference between control and component?

24. You ve defined one page_load event in aspx page and same page_load event in code behind how will prog run?

25. Where would you use an IHttpModule, and what are the limitations of any approach you might take in implementing one?

26. Can you edit data in the Repeater control? Which template must you provide, in order to display data in a 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 data source to the Repeater control?

27. What is the use of web.config? Difference between machine.config and Web.config?

Ans. ASP.NET configuration files are XML-based text files--each named web.config--that can appear in any directory on an ASP.NET
Web application server. Each web.config file applies configuration settings to the directory it is located in and to all
virtual child directories beneath it. Settings in child directories can optionally override or modify settings specified in
parent directories. The root configuration file--WinNT\Microsoft.NET\Framework\\config\machine.config--provides
default configuration settings for the entire machine. ASP.NET configures IIS to prevent direct browser access to web.config
files to ensure that their values cannot become public (attempts to access them will cause ASP.NET to return 403: Access
Forbidden).
At run time ASP.NET uses these web.config configuration files to hierarchically compute a unique collection of settings for
each incoming URL target request (these settings are calculated only once and then cached across subsequent requests; ASP.NET
automatically watches for file changes and will invalidate the cache if any of the configuration files change).

28. What is the use of sessionstate tag in the web.config file?

Ans. Configuring session state: Session state features can be configured via the section in a web.config file. To double the default timeout of 20 minutes, you can add the following to the web.config file of an application:
timeout="40"
/>
29. What are the different modes for the sessionstates in the web.config file?

Ans. Off Indicates that session state is not enabled.
Inproc Indicates that session state is stored locally.
StateServer Indicates that session state is stored on a remote server.
SQLServer Indicates that session state is stored on the SQL Server.

30. What is smart navigation?

Ans. When a page is requested by an Internet Explorer 5 browser, or later, smart navigation enhances the user's experience of the page by performing the following:
· eliminating the flash caused by navigation.
· persisting the scroll position when moving from page to page.
· persisting element focus between navigations.
· retaining only the last page state in the browser's history.
Smart navigation is best used with ASP.NET pages that require frequent postbacks but with visual content that does not change dramatically on return. Consider this carefully when deciding whether to set this property to true.
Set the SmartNavigation attribute to true in the @ Page directive in the .aspx file. When the page is requested, the dynamically generated class sets this property.

31. In what order do the events of an ASPX page execute. As a developer is it important to undertsand these events?

32. How would you get ASP.NET running in Apache web servers - why would you even do this?

33. What tags do you need to add within the asp:datagrid tags to bind columns manually

34. What base class do all Web Forms inherit from?

Ans. System.Web.UI.Page

35. How can we create pie chart in asp.net?

36. Is it possible for me to change my aspx file extension to some other name?

Ans. Yes.
Open IIS->Default Website -> Properties
Select HomeDirectory tab
Click on configuration button
Click on add. Enter aspnet_isapi details (C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\aspnet_isapi.dll | GET,HEAD,POST,DEBUG)

Open machine.config(C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\CONFIG) & add new extension under tag


37. What is AutoEventWireup attribute for ?

No comments: