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: What is a web-farm and how do u manage session in web-farm?
Answer: A web-farm is group of webservers hosting a single web application.
Sice the web application is shared across multiple servers, session info can
not be stored in process memory of any of servers. It should be stored in a
centralizes database or state machine.
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 cookieless session works in ASP.NET?
Answer: In cookieless session session id gets embedded in URL automatically. So
when url request is made, session id is stripped from URL by ASP.NET
And is used to identify session information belonging to user.
Question: Does cookieless session works when absolute paths are specified ?
Answer: No cookieless session does not work with absolute paths. It works only with
relative path.
Question: Is it possible to protect view state from tampering when it's passed over an
unencrypted channel?
Answer: Yes. Simply include an @ Page directive with an
EnableViewStateMac="true" attribute in each ASPX file you wish to
protect, or include the following statement in Web.config: his
configuration directive appends a hash (officially called the message
authentication code, or MAC) to view state values round-tripped to
the client and enables ASP.NET to detect altered view state. If
ASP.NET determines that view state has been altered when a page
posts back to the server, it throws an exception.
The hash is generated by appending a secret key (the
validationKey value attached to the
Machine.config) to the view state and hashing the result. An
attacker can't modify view state and fix up the hash without
knowing the secret key, too.
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 difference between canche.insert and cache.add method
Answer: The Add and Insert methods have the same signature, but there are subtle
differences between them. First, calling the Add method returns an object
that represents the cached item, while calling Insert does not. Second, their
behavior is different if you call these methods and add an item to the cache
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 fragment caching?
Answer: Fragment caching is caching enabled for ascx controls.
Question: How do u notify an application when an item is removed from the cache?
Answer: By implementing event CacheItemRemovedCallBack.
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: List two different exception-handling approaches in ASP.NET Web applications.
Answer: Exceptions can be handled in exception-handling blocks using the Try, Catch, and
Finally keywords in Visual Basic .NET or the try, catch, and finally keywords in
Visual C#. They can also be handled using Error event procedures at the Global,
Application, or Page levels using the Server object' s GetLastError and ClearError
methods.
Question: Write the HTML for a hyperlink that will send mail when the user clicks the link.
Answer: Send mail
Question: Show the code that writes a cookie containing the user name “Rob Young” and the
current date to the user' s computer. Set the cookie to remain on the user' s computer
for 30 days.
Answer: HttpCookie cookUserInfo = new HttpCookie("UserInfo")
CookUserInfo["Name"] = "Rob Young"
CookUserInfo["Time"] = DateTime.Now.ToString()
cookUserInfo.Expires = DateTime.Now.AddDays(30)
Response.Cookies.Add(cookUserInfo)
Question: What is the difference between the CurrentCulture property and the Current-
UICulture property?
Answer: The CurrentCulture property affects how the .NET Framework handles dates,
currencies, sorting, and formatting issues. The Current UICulture property
determines which satellite assembly is used when loading resources.
Question: How do you detect the user' s culture?
Answer: Use the Request object' s UserLanguages array. The value at element 0 corresponds
ASP.NET Questionnaire
Compiled by rsonidotnet@yahoo.com Page 7 of 20
to one of the culture codes used by the CultureInfo class. For example:
SLang = Request.UserLanguages(0)
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: Can an ASPX file contain more than one form marked runat="server"?
Answer: No
Question: How do I comment out statements in ASPX files?
Answer: <%--
--%>
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 wrong with the following line of code?
Server.Transfer("Default.htm");
Answer: You can' t use the Transfer method with HTML pages. It works only with .aspx
pages.
Question: How do you display a page in one frame from a hyperlink in another frame?
Answer: Use the element' s target attribute to specify the frame to display the page. For
example, the following hyperlink displays a page in the main frame of a frameset:
Show the answers!
Question: Briefly describe the best uses for each of the three types of Web controls
Answer: Create a user control when you want to…
…quickly create a group of controls that can be reused throughout a project to
perform some logical unit of work.
Create a composite custom control when you want to…
…combine one or more existing controls into a compiled assembly that can be easily
reused in many different projects.
Create a rendered control when you want to…
…build an entirely new control that can be compiled into an assembly for use in
multiple projects.
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 the most important method to override when creating a rendered control?
Answer: You override the Render method when creating a rendered custom control.
Question: What is the advantage of using CSS rather than in-line styles for formatting a Web
application?
Answer: Using CSS allows you to maintain formatting separately from the content of your
Web forms, so changes are easier to make and consistency is easier to maintain.
Question: How will u get or set the values from a CheckBoxList or RadioButtonList control?
Answer: , use a For Each loop to check each control in the list
private void Button1_Click(object sender,
System.EventArgs e)
{
foreach (ListItem lstItem in RadioButtonList1.Items)
{
if (lstItem.Selected)
Response.Write(lstItem.Text +
" is selected.
");
}
}
Question: Specify form tag which contains file upload control.
Answer:
No comments:
Post a Comment