Tuesday 21 January 2014

When I create a new ASP.NET 4 web application, the web.config file is almost empty. What happened to all the configuration elements that were there prior to ASP.NET 4?

                                                                                                                                        Previous....
                                                                                                                                                     Next.....



All the major configuration settings are moved into machine.config file, and all the applications will inherit the setting from this file. If an application needs to override the default settings, we can do so using the application specific configuration (web.config) file. ASP.NET 4 applications have clean web.config files.

If you create a new asp.net 4 empty web application, the only entry that you will find is shown below.


Note: If you create a new ASP.NET Web Application, instead of a new ASP.NET Empty Web Application, you will find a lot more confiuration entries in the web.config file. This is because, the template for ASP.NET web application overrides some of the default settings inherited from machine.config.



ASP.NET Page is very slow. What will you do to make it fast

This is a very common asp.net interview question asked in many interviews. There are several reasons for the page being slow. We need to identify the cause. 

1. Find out which is slow, is it the application or the database : If the page is executing SQL queries or stored procedures, run those on the database and check how long do they take to run. If the queries are taking most of the time, then you know you have to tune the queries for better performance. To tune the queries, there are several ways and I have listed some of them below.
   a) Check if there are indexes to help the query
   b) Select only the required columns, avoid Select *.
   c) Check if there is a possiblity to reduce the number of joins
   d) If possible use NO LOCK on your select statements
   e) Check if there are cursors and if you can replace them with joins


Difference between EnableViewState and ViewStateMode properties



1. Using EnableViewState property we only have 2 options
     We can turn off view state altogether,
                              or
     Enable viewstate for the entire page and then turn it off on a control-by-control basis.

2. If you want to turn of ViewState for the entire page and only enable it for specific controls on the page, then we have to use ViewStateModeproperty in conjunction with EnableViewState.

3. EnableViewState property only accepts true or false values and the default value is true, where as ViewStateMode property can have a value of - Enabled, Disabled and inherit. Inherit is the default value for ViewStateMode property.

4. ViewStateMode property is introduced in ASP.NET 4, where as EnableViewState exists from a long time.

5. If EnableViewState is to True, only then the ViewStateMode settings are applied, where as, if EnableViewState is set to False then the control will not save its view state, regardless of the ViewStateMode setting. In short if EnableViewState is set to False, ViewStateMode setting is not respected.

6. To disable view state for a page and to enable it for a specific control on the page, set the EnableViewState property of the page and the control to true, set the ViewStateMode property of the page to Disabled, and set the ViewStateMode property of the control to Enabled.


These are the different types of extensions in Dot Net Files 
.
» .aspx- Web Form 
» .master - Master Page 
» .ascx - WebUserControl 
» .edmx - Ado Entity data Model
» .cs - Class file
» .rpt - CrystalReport
» .xsd - DataSet1
» .ascx - DynamicDataField
» .htm - HTMLPage
» .csproj - SilverlightApplication
» .mdf - Sql Server Database
» .config - web configuration file
» .asmx -web services
» .xml - XML file
                                                                                                                                       Previous....
                                                                                                                                                     Next.....





No comments:

Post a Comment

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...