Buy our 600+ interview questions videos package

RSS

Posts tagged with "ASP.NET interview questions"

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.

3 Important Concepts: - Association, Aggregation and Composition.

Introduction

Extracting real world relationships from requirement

Requirement 1 (The IS A relationship)

Requirement 2 (The Using relationship: - Association)

Requirement 3 (The Using relationship with Parent: - Aggregation)

Requirement 4 and 5 (The Deathrelationship: - Composition)

Putting things together

The source code

Summarizing

Video on Association, Aggregation and Composition

Introduction

In this article we will try to understand 3 important concepts association, aggregation and composition.

We will also try to understand in what kind of scenarios do we need them. These 3 concepts have really confused lots of developers and in this article my attempt would be to present the concepts in a simplified manner with some real world examples.

Extracting real world relationships from requirement

The whole point of OOP is that your code replicates the real world object, thus making your code readable and maintainable. The time we say real world, real world have relationships. Let’s consider the simple requirement listed below:-

  1. Manager is anemployee of XYZ limited corporation.
  2. Manager uses a swipe card to enter XYZ premises.
  3. Manager has workers who work under him.
  4. Manager has the responsibility of ensuring that the project is successful.
  5. Manager’s salary will be judged based on project success.

If you flesh out the above 5 point requirement we can easily visualize 4 relationships:-

  • Inheritance
  • Aggregation
  • Association
  • Composition

Let’s understand them one by one.

Requirement 1 (The IS A relationship)

If you see the first requirement (Manager is an employee of XYZ limited corporation) it’s a parent child relationship or inheritance relationship. The sentence above specifies that Manager is a type of employee, in other words we will have two classes one the parent class “Employee” and the other a child class “Manager” which will inherit from “Employee” class.

Note: -The scope of this article is only limited to aggregation, association and composition. So we will not discuss inheritancein this article as its pretty straight forward and I am sure you can get1000 of articles on the net which will help you in understanding the same.

Requirement 2 (The Using relationship: - Association)

The requirement 2 is an interesting requirement (Manager uses a swipe card to enter XYZ premises). In this requirement the manager object and swipe card object use each other but they have their own object life time. In other words they can exist without each other. The most important point in this relationship is that there is no single owner.

image

The above diagram shows howthe “SwipeCard” class uses the “Manager” class and the “Manager” class uses the “SwipeCard” class. You can also see how we can create the object of the “Manager” class and “SwipeCard” independently and they can have their own object life time.

This relationship is called as the “Association” relationship.

Requirement 3 (The Using relationship with Parent: - Aggregation)

The third requirement from our list (Manager has workers who work under him) denotes the same type ofrelationship like association but with a difference that one of them is an owner. So as per the requirement the “Manager” object will own “Workers” object.

The child “Worker” objects can not belong to any other objects. For instance the “Worker” object cannot belong to the “SwipeCard” object.

But But….the “Worker” object can have his own life time which is completely disconnected from the “Manager” object. Looking from a different perspective it means that if the “Manager” object is deleted the “Worker” object does not die.

This relationship is termed as the “Aggregation” relationship.

image

Requirement 4 and 5 (The Deathrelationship: - Composition)

The last two requirements are actually logically one. If you read closely both the requirements which are as follows:-

  1. Manager has the responsibility of ensuring that the project is successful.
  2. Manager’s salary will be judged based on project success.

Below is the conclusion from analyzing the above requirements:-

  1. Manager and the project objects are dependent on each other.
  2. The lifetimes of both the objects are same. In other words the project will not be successful if the manager is not good and manager will not get good increments if project has issues.

Below is how the class formation will look like. You can also see when I go to create the project object it needs the manager object.

image

This relationship is termed as the composition relationship. In this relationship both objects are heavily dependent on each other. In other words if goes for garbage collection the other also has to garbage collected , or putting from a different perspective the life time of the objects are same. That’s why I have put in the heading “Death” relationship.

Putting things together

Below is a visual representation of how the relationships have emerged from the requirements.

image

The source code

You can also download source code for this article

Summarizing

To avoid confusion hence forth in these 3 terms I have put forward a table below which will help us compare them from 3 angles owner , life time and child object.

image

Video on Association, Aggregation and Composition

I have also added a video in case you do not want to read this long article.

Just a note I have recorded around 500 videos, do have once a look at my videos on .NET, OOP, SQL Server, WCF, Silver light , LINQ , VSTS, Share Point, Design patterns , UML and lot more.

Visit to get more stuff on important Dotnet interview questions

Regards,

Also visit for more author’s other blogs on Most asked .NET interview questions

.NET interview questions: - How will you elaborate project life cycle?

This is basic of .NET interview questions which are mostly asked to 1 year experience and above candidates.

So here is a simplified answer we have put in front with a diagram so that you can learn in a more easier manner.

image

                       Figure: - Life cycle of a project

There are five stages of any project initiating, planning, executing, controlling, and closeout. These are general phases and change according to domain. Example when writing a book we will have the following mappings initiating (contacting publishers, getting copy right etc), planning (Table of contents of book, Number of chapters, tool to use, chapter wise deadlines etc), executing (Actually writing the book), controlling (proof reading, language checks, page alignments etc), and closeout (Finally printing and on the shelf for sale). Therefore, this classification is at very broader level, for software development the above figure shows the mapping.

During Software project management interview, expected answer is requirement phase, design phase, coding phase, testing phase, and project closure. But you can just impress the answer by giving a general answer and then showing the mapping.

Also see a question for differences between Abstraction and Encapsulation based on OOPS as follows: -

Learn more on interview questions and answers for .NET

Regards,

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