ASP.NET Questions


Question: Why a conventional ASP web page is considered to be stateless amd how  do u overcome this using ASP.NET?
Answer: Whenver a URL request is made, Web server creates instance of requested web form, generates HTML and posts it to browser for rendering. It then destroys instance of web form on the server.  When user submits data back to the web server,  a new instance of web form is created which has no knowledge of earlier webform. Hence conventional  web page is stateless. In ASP.NET before web form get destroyed the state of the webform is stored in Viewstate(hidden control) on the page and when the page is posted back, the state of the webform is restored from view state.



Question: How do you preserve persistent data, such as simple variables, in a Web application?
Answer: You can preserve data in state variables, such as ApplicationState, SessionState, or ViewState.



Question: How do u synchronize access to Application variables by multiple threads.
Answer:  Use Application.Lock and Application.Unlock before accessing Application Variables.




Question: How do u cache a web page in ASP.NET?
Answer:  <%@ outputcache duration=”60” varybyparam=”none”>




Question: What is difference between following statements
1 - <%@ outputcache duration=”60” varybyparam=”none”>
2 - <%@ outputcache duration=”60” varybyparam=”*”>
3 - <%@ outputcache duration=”60” varybyparam=”name”>
 Answer:  Statement 1 caches only one version of the page irrespective of querystring parameters. Statement 2 caches multiple versions of same page I any of quewrystring parameter varies. Statement 3 caches multiple versions of the page for different values of parameter xyz.




Question: What is cache dependency and how do u add it?
Answer:  If object1 has Cache dependency on object2 , then whnever object2  changes, object1 is removed from the cache. e.g. following example sets up a database connection string denedency on xml file.
Cache.Insert("MyData1", connectionString, new CacheDependency(Server.MapPath(\\myServer\myConfig.xml)));




Question: What are 2 expiration policies for Cached objects?
Answer:  1. Absolute expiration: This is fixed duration expiration. For cache duration of 10 seconds, object is removed from cache  after 10 seconds no matter what.
2. Sliding expiration:  Canche duration varies based on frequency of access. E.g. If there is sliding expiration of 10 seconds and item is accessed from the cached again at 8th second, then object is reached again for the next 10 seconds




Question: What is the main difference between the Button server control and the Button HTML control?
Answer: When clicked, the Button server control triggers an ASP.NET Click event procedure on the server. The Button HTML control triggers the event procedure indicated in the button' s onclick attribute, which runs on the client.




Question:  What are 2 layout options for a webform
Answer : Grid layout:  This is the default. Controls are placed exactly where you draw them and they have absolute positions on the page. Use grid layout for Windows-style applications, in which controls are not mixed with large amounts of text.
Flow layout:  This places controls relative to other elements on the page. If you add elements at run time, the controls that occur after the new element move down. Use flow layout for document-style applications, in which text and controls are intermingled.




Question : How do you get several RadioButton controls to interoperate on a Web form so that only one of the RadioButtons can be selected at once?
Answer: Set the GroupName property of each RadioButton to the same name.




Question: What is the most important method to override when creating a composite custom control?
Answer: You override the CreateChildControls method to add existing controls to a composite custom control.




Question : What is difference between click event of a simple link button and image  button  control?
Answer: Using the Button and LinkButton Click event procedure is straightforward. The ImageButton control provides an additional capability. The Click event argument for the ImageButton control includes the X and Y coordinates for where the user clicked on the control. The image response depends on where it Images that respond to clicks in this way are called image maps.




Question : What if some one types the web.config file in the URL?
Answer: 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).
Question : What is the difference between the Debug and Trace classes?
Answer: Under the default environment settings, code using the Debug class is stripped out of release builds, while code using the Trace class is left in. The classes are otherwise equivalent.




Question : Which ASP.NET authentication mode is best suited to identifying and authorizing users who belong to a corporate network?
Answer: Windows integrated authentication is best suited to authenticating users of a corporate network because it uses the accounts and permissions that already exist for network users.

No comments