ASP.NET Interview Questions and Answers (1544) - Page 11

Can we delete directory having other directory and files?

Yes, we can delete directories directly that have files and other directories using

System.IO.Directory.Delete("Directory Path", true);

How can we copy the file from one location to other?

Using File.Copy Method we can copy the file from one location to other.

System.IO.File.Copy("Source File Path", "Destination File Path");

What is a primary difference between the standard validator controls and the mobile validator controls?

The mobile validation controls don’t provide client-side validation.
What is the unit of the Duration property in the OutputCache directives of the UserControl in asp.net

The unit of the OutputCache duration is #ofseconds.

This is specified in number of seconds.

<%@ OutputCache Duration="60" Shared="True" VaryByParam="None" %>


Above code will cache the user control for 60 seconds ie. 1 minute and the same cached user control will be shared across whole website (as Shared property is set to true).

For more details, visit http://msdn.microsoft.com/en-us/library/hdxfb6cy.aspx

Thanks
What is a web garden?

By default an application pool runs with a single worker process (w3wp.exe). We can allocate multiple worker process in a single application pool. An application which can have multiple W3WP process, is known as web Garden.
What are the main components of IIS 7.0?

Main Components of IIS 7.0 are HTTP.Sys, Svchost.Exe, Application Pool , Worker Process (W3WP.exe) and Configuration Store.
What is cross page posting in ASP.NET?

Sometimes, other than round-trip cycle of asp.net web page we need to post one page to another page by configuring controls to be posted to different target page. This is referenced as cross page posting in ASP.NET.
What is difference between ResolveUrl and ResolveClientUrl ? Which do you prefer to use?

ResolveUrl - Returns URL relative to the site root using control’s TemplateSourceDirectory property.

ResolveClientUrl – Returns URL relative to the folder containing the source file in which the control is instantiated.

I would prefer to use ResolveUrl as URL returned can be used anywhere in the site to make it work correctly.

Thanks,
Bhakti Shah
With which method you can set design-time data for a control ?

NOTE: This is objective type question, Please click question title for correct answer.
Which method will you use to Delete the view-state information for all the server control's child control(s)?

NOTE: This is objective type question, Please click question title for correct answer.
Which property do you use to determine how ASP.NET page was invoked?

NOTE: This is objective type question, Please click question title for correct answer.
Explain AdRotator control.

AdRotator control is used to present ad images clicking which we can navigate to another web location. With each page load,ad image can be selected randomly or in specified order from predefined well formatted XML document.
Well formatted XML document(Advertisement File) contains required information for the image that needs to be displayed.

Elements of the Advertisement File:
ImageUrl: Advertisement Image URL(Absolute/relative)
NavigateUrl: Destination web location where user needs to be directed when he clicks the image (if NavigateUrl is not set then image is not clickable)
AlternateText: [Optional parameter]Text when the user moves mouse pointer over the image
Keyword: [Optional parameter] Keyword
Impressions: [Optional parameter] Number indicating weight of the ad in the order of rotation with respect to other ads in the file
What is persistent and non-persistent cookie?

Persistent Cookies : This can be said as permanent cookies, which gets stored on user's machine. For persistent cookie, one need to set the expiry date.

Non Persistent Cookies : This is Temporary Cookies which get's stored in browser's memory.
What is difference between System.Web.Caching.Cache and System.Web.HttpContext.Current.Cache ?

System.Web.Caching.Cache : Class/type used for caching
System.Web.HttoContect.Current.Cache: Instance of cache class for current HTTP context from a web request (Gets cache object from current application domain)
What is Cookie Munging?

By default, asp.net uses cookies to store session id for the logged in user. But there is an option in every browser to disable cookies. If cookies are disabled, then any website will not be able to create cookies on user's machine.

When cookies are disabled, then session Id is gets appended in the URL and passed to the server. Server decodes it and fulfill the requested page.

Cookie Munging is nothing but how ASP.NET manages session variables without cookies.

Thanks,
Virendra Dugar
What is the difference between Session.Clear() and Session.RemoveAll() method?

Well, actually there is no difference. Session.RemoveAll() methods internally makes a call to Clear() method only.

Thanks.
Is it possible to set SessionState to readonly mode? Readonly mode means, we can only read data from session but we can not write any data in session variable?

Yes, it is possible.
EnableSessionState property has a value "Readonly" which actually makes the session state read only.

Thanks.
Is it possible to use InProc mode for sessionState in case of web garden?

No, it's not possible. As InProc mode is dependent on the worker process and in case of web garden, we have multiple worker process so session handling becomes difficult. Either we can use StateServer or SQL server mode for web garden.

Thanks.
Explain Server.URLEncode Method.

This method applies URL encoding rules, including escape characters. Where Spaces are converted to plus signs and non-alphanumeric characters are converted to their hexadecimal codes.

For an example,
Response.Write(Server.UrlEncode("http://testurl encode 123.com"));


Will result,
http%3a%2f%2ftesturl+encode+123.com
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories