Buy our 600+ interview questions videos package

RSS

Posts tagged with "ASP.NET interview questions"

QuestPond’s Interview Questions & Answers on ASP.NET

How can we identify that the Page is Post Back?

Page object has an “IsPostBack” property, which can be checked to know t the page is posted back.

What is the use of Smart Navigation property?

It’s a feature provided by ASP.NET to prevent flickering and redrawing when the page is posted back.

In which event are the controls fully loaded?

Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event.

Where is View State information stored?

In HTML Hidden Fields.

What is the use of @ Register directives?

@Register directive informs the compiler of any custom server control added to the page.

What is AppSetting Section in “Web.Config” file?

Web.config file defines configuration for a web project. Using “AppSetting” section, we can define user-defined values. Example below is a “Connection String” section, which will be used throughout the project for database connection.

image

See following video on Web.config transformation: -

Click and see here for more step by step learning ASP.NET.

Jul 4

QuestPond: Interview Questions and Answers on learning ASP.NET

How can we create custom controls in ASP.NET?

User controls are created using .ASCX in ASP.NET. After .ASCX file is created you need to two things in order that the ASCX can be used in project:.

  • Register the ASCX control in page using the <percentage@ Register directive.Example

  • Now to use the above accounting footer in page you can use the below directive.

image

How many types of validation controls are provided by ASP.NET?

There are six main types of validation controls:-

RequiredFieldValidator
It checks whether the control have any value. It is used when you want the control should not be empty.

RangeValidator
It checks if the value in validated control is in that specific range. Example TxtCustomerCode should not be more than eight lengths.

CompareValidator
It checks that the value in controls should match some specific value. Example Textbox TxtPie should be equal to 3.14.

RegularExpressionValidator
When we want the control, value should match with a specific regular expression.

CustomValidator
It is used to define User Defined validation.

Validation Summary
It displays summary of all current validation errors on an ASP.NET page.

How can we force all the validation control to run?

Page.Validate

How can we check if all the validation control is valid and proper?

Using the Page.IsValid () property you can check whether all the validation are done.

See following video on ASP.NET Web.config transformation: -

Click and see here for more stuff on complete learning tutorials on ASP.NET.

ASP.NET interview questions: - Can you explain master pages concept in ASP.NET and how do you create master pages?

Master pages are templates which can be applied to your web pages to bring in consistent look and feel and uniform structure. By creating templates we also avoid lot of duplication of code across web pages.

For example let’s say you want all your web pages in your application to have left menu, banner and footer (Refer figure Master page concept). So you can create a template and then apply that template to your webpages.

image

Creating Master Pages: -

To create a master page you can use the “master page” template from visual studio as shown in the below figure. In order to apply the master template we can use “Web form using master page” template.

image

image

In the master page you can define place holder using “ContentPlaceHolder” control. This is the place where your ASP.NET pages will be plug in their data.

image

Once master page template is created with necessary place holders you can then later in the web pages use the “MasterPageFile” to refer the template and you can use the content place holder to plug data.

For instance you can see the below code snippet of a page which uses master pages. You can also see how the “ContentPlaceHolder1” is used to place a simple text data “Company was established in 1990”.

image

Also see the following ASP.NET interview questions video on ASP.NET Masterpages: -

Feb 4

ASP.NET interview questions: - Explain Application object and Cache object?

Application object is used when we want data to be shared across users globally in an ASP.NET application.What is the use of cache object?

What is the use of cache object?
It also does the same thing as the application object i.e. sharing and caching global data across ASP.NET pages in a web application.

What is the difference between Cache object and application object?
The main difference between the Cache and Application objects is that the Cache object provides features, such as dependencies and expiration policies.

How can get access to cache object?
The Cache object is defined in the ‘System.Web.Caching’ namespace. You can get a reference to the Cache object by using the Cache property of the HttpContext class in the ‘System.Web’ namespace or by using the Cache property of the Page object.

What are dependencies in cache and types of dependencies?
When you add an item to the cache, you can define dependency relationships that can force that item to be removed from the cache under specific activities of dependencies.Example if the cache object is dependent on file and when the file data changes you want the cache object to be update. Following are the supported dependency:-

  • File dependency: - Allows you to invalidate a specific cache item when a disk based file or files change.
  • Time-based expiration: - Allows you to invalidate a specific cache item depending on predefined time.
  • Key dependency:- Allows you to invalidate a specific cache item depending when another cached item changes.

Also click andsee the following ASP.NET interview questions video onSession vs Viewstate difference.

ASP.NET interview questions: - What are partial classes in ASP.NET?

A partial class allows a single class to be divided in to two separate physical files. During compile time these files get compiled in to single class. For instance you can see in the below figure we have the customer class divided in to two different files “customer1.cs” and “customer2.cs”.

During compilation these files gets compiled in to single class internally. So when you create an object of the customer class you will be able to see methods lying in both the physical files. For instance you can see “Add” method belongs to “customer1.cs” and “Delete” method belongs to “customer2.cs” , but when the customer object is created we can see both “Add” and “Delete” methods.

image

                                                      Figure: - Partial classes

Above is the ASP.NET interview questions & also see the following video on Web.config transformation:  -

Jan 2

ASP.NET interview questions: - Show us how will you configure “Web Garden”?

“Web garden” can be configured by using process model settings in “machine.config” or “Web.config” file. The configuration section is named <process Model> and is shown in

See the following example. The process model is enabled by default (enable=”true”). Below is the snippet from config file.

From the above process model section for web garden, we are concerned with only two attributes “web garden” and “cpuMask”.

WebGarden: - Controls CPU affinity. True indicates that processes should be affinities to the corresponding CPU. The default is False.

CpuMask:- Specifies which processors on a multiprocessor server are eligible to run ASP.NET processes. The cpuMask value specifies a bit pattern that indicates the CPUs eligible to run ASP.NET threads. ASP.NET launches one worker process for each eligible CPU. If web Garden is set to false, cpuMask is ignored and only one worker process will run regardless of the number of processors in the machine. If web Garden is set to true, ASP.NET launches one worker process for each CPU that corresponds to a set bit in cpuMask. The default value of cpuMask is 0xffffffff. 

Below are detail steps of how to implement web garden

  • Click Start and then click Run.
     
  • Type calc.exe and then click OK.
     
  • Go to View menu, click Scientific.
     
  • Go to View menu, click Binary.
     
  • Use zero and one to specify the processors ASP.NET can or cannot use.

Use one for the processor that you want to use for ASP.NET. Use 0 for the processor that you do not want to use for ASP.NET. For example, if you want to use the first two processors for ASP.NET of a four-processor computer, type 1100.

  • On the View menu, click Decimal. Note the decimal number.
     
  • Open the Web.config or machine.config file in a text editor such as Notepad. The Web.config file is located in the folder where the application is saved.
     
  • In the Web.config file, add the process Model configuration element under the System. Web element. Before adding <process Model> to Web.config file, the user has to make sure that the allow Definition attribute in the <process Model> section of the Web.config file is set to everywhere.

  • Add and then set the web Garden attribute of the process Model element to True.

  • Add and then set the cpuMask attribute of the process Model element to the result that is determined in your calculation.

Do not preface the number with zerox because the result of the calculation is a decimal number. The following example demonstrates the process Model element that is configured to enable only the first two processors of a four-processor computer.

Save the Web.config file. The ASP.NET application automatically restarts and uses only the specified processors.

See the following ASP.NET interview questions video on ASP.NET Masterpages:  -

ASP.NET interview questions: - When to use what? - “Server.Transfer” or “Response.Redirect”

Use “Server.Transfer” when you want to navigate pages which resides on the same server , use ‘Response.Redirect’ when you want to navigate between pages which resides on different server.

image

Response.Redirect(URL,true) vs Response.Redirect(URL,false) ?

                                 image

Response.Redirect(URL,false) :- Client is redirected to a new page and the current page on the server will keep processing ahead.

Response.Redirect(URL,true) :- Client is redirected to a new page but the processing of the current page is aborted.

Also see following ASP.NET interview questions video on importance of session and viewstate  

ASP.NET interview questions: - Which are the various modes of storing ASP.NET session?

  • InProc: - In this mode Session, state is stored in the memory space of the Aspnet_wp.exe process. This is the default setting. If the IIS reboots or web application restarts then session state is lost.
  • StateServer:-In this mode Session state is serialized and stored in a separate process (Aspnet_state.exe); therefore, the state can be stored on a separate computer(a state server).
  • SQL SERVER: - In this mode Session, state is serialized and stored in a SQL Server database.

Session state can be specified in <sessionState> element of application configuration file. Using State Server and SQL SERVER session state can be shared across web farms but note this comes at speed cost as ASP.NET needs to serialize and deserialize data over network repeatedly.

See the below ASP.NET interview questions video on ASP.NET Masterpages

May 3

ASP.Net Interview questions: - What is the difference between ‘Server. Transfer’ and ‘response.Redirect’?

Following are the major differences between them:-

‘Response. Redirect’ sends message to the browser saying it to move to some different page, while server. Transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in ‘server. Transfer’ there is no round trip while ‘response. Redirect’ has a round trip and hence puts a load on server.

Using ‘Server. Transfer’ you cannot redirect to a different from the server itself. Example if your server is www.yahoo.com you cannot use server. Transfer to move to www.microsoft.com but yes, you can move to www.yahoo.com/travels, i.e. with in websites. Cross server redirect is possible only by using Response. Redirect.

With ‘server. Transfer’ you can preserve your information. It has a parameter called as “preserveForm”.Therefore, the existing query string etc. will be able in the calling page.

If you are navigating within the same website use “Server. Transfer” or else go for “response.Redirect ()”

See the following video on ASP.NET4.0: -

Click for more ASP.NET interview questions

Regards,

Visit for more Authors’ blog on ASP.NET interview questions

ASP.NET interview questions: - Difference between ASP and ASP.NET?

This is the most practical oriented ASP.NET Interview Questions which may be asked during the Interview by the Interviewer.

ASP.NET new feature supports are as follows:-

Better Language Support

  • New ADO.NET Concepts have been implemented.
  • ASP.NET supports full language (C#, VB.NET, C++) and not simple scripting like VBSCRIPT…

Better controls than ASP

  • ASP.NET covers large set’s of HTML controls..
  • Better Display grid like Data grid, Repeater and datalist.Many of the display grid havpaging support.

Controls have events support

  • All ASP.NET controls support events.
  • Load, Click, and Change events handled by code makes coding much simpler and much better organized.

Compiled Code

ASP.NET supports forms-based user authentication, including cookie management and automatic redirecting of unauthorized logins. (You can still do your custom login page and custom user checking).

Better Authentication Support

ASP.NET supports forms-based user authentication, including cookie management and automatic redirecting of unauthorized logins. (You can still do your custom login page and custom user checking).

User Accounts and Roles

ASP.NET allows for user accounts and roles, to give each user (with a given role) access to different server code and executables.

High Scalability

  • Much has been done with ASP.NET to provide greater scalability.
  • Server to server communication has been greatly enhanced, making it possible to scale an application over several servers. One example of this is the ability to run XML parsers, XSL transformations, and even resource hungry session objects on other servers.

Easy Configuration

  • Configuration of ASP.NET is done with plain text files.
  • Configuration files can be uploaded or changed while the application is running. No need to restart the server. No more metabase or registry puzzle.

Easy Deployment

No more server restart to deploy or replace compiled code. ASP.NET simply redirects all new requests to the new code.

See the following video on ASP.NET for importance of session and view state: -


Click for more ASP.NET interview questions

Regards,

Visit for more Authors’ blog on ASP.NET interview questions

ASP.NET interview questions: - Can you explain in brief how the ASP.NET authentication process works?

ASP.NET does not run by itself, it runs inside the process of IIS. Therefore, there are two authentication layers, which exist in ASP.NET system. First authentication happens at the IIS level and then at the ASP.NET level depending on the WEB.CONFIG file.

Below is how the whole process works:-

  • IIS first checks to make sure the incoming request comes from an IP address that is allowed access to the domain. If not it denies the request.
  • Next IIS performs its own user authentication if it is configured to do so. By default IIS allows anonymous access, so requests are automatically authenticated, but you can change this default on a per – application basis with in IIS.
  • If the request is passed to ASP.NET with an authenticated user, ASP.net checks to see whether impersonation is enabled. If impersonation is enabled, ASP.net acts as though it were the authenticated user. If not ASP.net acts with its own configured account.
  • Finally, the identity from step 3 is used to request resources from the operating system. If ASP.net authentication can obtain all the necessary resources it grants the users request otherwise it is denied. Resources can include much more than just the ASP.net page itself you can also use .NET’s code access security features to extend this authorization step to disk files, Registry keys and other resources.

See the following video on ASP.NET Forms authentication by using session hijack: -

Click for more ASP.NET interview questions

Regards,

Visit for more Author’s blog on ASP.NET interview questions

ASP.NET interview questions: - What are benefits and limitations of using Query Strings?

A simple but most frequently asked ASP.NET interview question.

A query string is information sent to the server appended to the end of a page URL.

Following are the benefits of using query string for state management:-

  • No server resources are required. The query string containing in the HTTP requests for a specific URL.
  • All browsers support query strings.

Following are limitations of query string:-

  • Query string data is directly visible to user thus leading to security problems.
  • Most browsers and client devices impose a 255-character limit on URL length.

See the following video on ASP.NET for importance of session and viewstate: -

Explore for more ASP.NET interview questions tutorials.

Regards,

From Author’s blog see other blog links ASP.NET interview questions

ASP.NET Interview questions: - What is the use of session and viewstate in ASP.NET?

HTTP is a stateless protocol , session and viewstate help you to maintain states between request and response.

For more information see the below video.

Click for more ASP.NET Interview questions

Regards,

Visit for more authors’ blog on ASP.NET Interview questions

ASP.NET interview questions: - What is the difference between trace and debug in ASP.NET?

There is also a fundamental difference in thinking when we want to use trace and when want to debug. Tracing is a process about getting information regarding program’s execution. On the other hand debugging is about finding errors in the code.

Debug and trace enables you to monitor the application for errors and exception without VS. NET IDE.

In Debug mode compiler inserts some debugging code inside the executable. As the debugging code is the part of the executable they run on the same thread where the code runs and they do not given you the exact efficiency of the code ( as they run on the same thread). So for every full executable DLL you will see a debug file also as shown in figure ‘Debug Mode’.

      

                                                   Figure: - Debug mode

Trace works in both debug as well as release mode. The main advantage of using trace over debug is to do performance analysis which cannot be done by debug. Trace runs on a different thread thus it does not impact the main code thread.

See the following video for how to Skip debugging in ASP. NET: -

Click for more ASP. NET Interview questions

Regards,

Visit for more authors’ blog on ASP. NET Interview questions

Mar 1

ASP.NET Interview Questions: - What is Post Cache substitution?

This is one of the asked ASP.Net Interview Questions during the Interview by the Interviewer.

Post cache substitution is used when we want to cache the whole page but also need some dynamic region inside that cached page. Some examples like QuoteoftheDay, RandomPhotos, and AdRotator etc. are examples where we can implement Post Cache Substitution.

Post-cache substitution can be achieved by two means:

  • Call the new Response.WriteSubstitution method, passing it a reference to the desired substitution method callback.
  • Add a <asp:Substitution> control to the page at the desired location, and set its methodName attribute to the name of the callback method.

      

                           Figure: - “Writesubstitution” in action

You can see we have a static function here “GetDateToString()”. We pass the response substitution callback to the “WriteSubstitution” method. So now, when ASP.NET page framework retrieves the cached page, it automatically triggers your callback method to get the dynamic content. It then inserts your content into the cached HTML of the page. Even if your page has not been cached yet (for example, it’s being rendered for the first time), ASP.NET still calls your callback in the same way to get the dynamic content. So you create a method that generates some dynamic content, and by doing so you guarantee that your method is always called, and it’s content is never cached.

Ok the above example was by using “WriteSubstitution” now lets try to see how we can do by using “<asp:Substitution>” control. You can get the “<asp:Substitution>” control from the editor toolbox.

                

                                  Figure: - Substitution Control

            

                                     Figure: - Substitution in Action

Below is a sample code that shows how substitution control works. We have ASPX code at the right hand side and class code at the behind code at the left hand side. We need to provide the method name in the “methodname” attribute of the substitution control.

View following video on Web.config transformation in ASP .Net: -

Learn more on ASP.NET interview questions

Regards,

From more on author’s blog related to ASP.NET interview questions click and visit.