Thursday, April 27, 2006

Presented here is a nice article on Asp.Net optimization.. Via John Belthoff

************

If you read all of the websites dedicated to Asp.Net you will inevitably read about the wonders of the DataGrid, DataList, and Repeater controls. While each of these has its place, if you are only displaying data there is a much faster and more efficient means to do so. A normal asp page execution procedure goes something like this. The code queries the database based on the Article I.D. and then brings back that information to the page where you display it in the fashion that you would like. This is a fairly straight forward approach with asp and is done all the time.

So how do we speed up our asp.net pages?

Number 1: Use Asp.Net Caching!

This is a no-brainer, and I won't go into the brilliance or details of asp.net caching here because at the time of this writing Google has 2,780,000 articles on the topic. Basically instead of querying the database each time the page is loaded you only query the database once and load that result into the system cache. Subsequent calls to load the page retrieve the data from the cache as opposed to the database which gives you an instant and considerable performance boost. You can then set the cache for how long the cache should store the information as well as many other features. If you are not using the cache, you should be whenever possible!

Number 2: If possible, do NOT use the standard Asp.Net controls.

That's right. The standard asp.net controls are designed for rapid development and not page performance. They allow you to design pages that grab and display data very quickly but their actual performance suffers because of the extra overhead which is there for ease and speed of development time and not page execution speed.

Instead, create either a User Control or even better yet a Web Custom Control which is by far the fastest performance wise and really quite easy to create and use.

Number 3: Use an SqlDataReader or even better yet use a set based command for Sql Server data retrieval and simply execute that one command against the database.

An asp.net SqlDataReader is a fast forward only datareader that closes the connection after it reads the last set of results. Now for my article pages we are only returning 1 particular result. In this case we would opt for the set based command. If you had more than 1 result returned, in your table of contents for instance, you would use the SqlDataReader because you are returning multiple sets of results.

Set based commands are stored procedures that bring back data through parameters as opposed to a result set which then in turn needs to be looped through to obtain your data. So instead of writing your stored procedure like the following which brings back 1 result set:

Select Title, Body, Author
From Articles
Where ArtID = 215


We can write it using a set based command like this.

Create Procedure mysp_GetArticle

@Title varchar(200) Output,
@Body varchar(8000) Output,
@Author varchar(500) Output

As

Select @Title = Title, @Body = Body, @Author = Author
From Articles
Where ArtID = 215

GO


The above query will return only the three parameters called for and not a result or record set so you don't have to then walk through the returned record set that has only 1 result in it anyway. This second little process of work decreases your performance so you should avoid it whenever possible. Combine this technique with the asp.net cache.

Number 4: Use Classes and ArrayLists as opposed to returning an SqlDataReader.

Create a class and then if there are more than one set of results store those results into individual instantiations of that class. Finally store each of those classes into an ArrayList. You can then store only that ArrayList into the asp.net cache. So instead of getting the results back from a SqlDataReader when loading your page you get them from the ArrayList which is stored in the cache. Nice huh?

Finally... you want to incorporate all of these techniques into your final results which would be performed in the following manner and sequence.

On the first time the page loads, query the database and return all of your data storing it into individual classes. Then store each of those classes into an ArrayList. If you only have one single result you may store only the class into the cache. Then take your ArrayList and store it into the cache.

Next create a Web Custom Control and pass the cached ArrayList to the custom control and loop out your data using the HtmlTextWriter which is very fast. Remember each subsequent call to load the page will be called from the cache which stores your ArraList of classes or your single class.

Certainly it takes a significant amount of additional coding to do it in this fashion, especially when you take proper error handling into consideration, but if you follow this approach your pages will be screeching fast, you will immediately notice the difference, and your asp.net pages will execute in the proper sequence - Data handling in the Page_Load function and the html display in the Page_Render function.

Further, you will be glad you did and so will your visitors.

************

posted on Thursday, April 27, 2006 1:23:39 PM (Central Standard Time, UTC-06:00)  #    Comments [1] Trackback
 Tuesday, March 21, 2006

To examine the advantages and disadvantages of software outsourcing, as well as the application of lean principles to software development, Harvard Business School has done a case study on Wipro's innovative Factory Model approach. It specifically explores Wipro's experimental use of lean principles as a source of new competitive advantage in software services.

The case study addresses the advantages and disadvantages of software outsourcing and how to mitigate the effects of, for example, lock-in and hijacking. Explores how Wipro has helped its customers deal with these issues and looks at the changing competitive role of Indian outsourcers (from low-cost, to high-quality/rapid turnaround). Specifically explores Wipro's experimental use of lean principles as a source of new competitive advantage in software services. Also addresses the issue of standardization in information technology, examining why companies progressively develop so many standards and how companies like Wipro can help them standardize, thus limiting one of the primary drivers of companies' IT costs.

A copy of the case study can be retained from either Wipro or Harvard Business School.

posted on Tuesday, March 21, 2006 11:25:34 AM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback
 Wednesday, March 15, 2006

VISIBILITY.net is one of the first Enterprise business applications to be written from the outset entirely using Microsoft.NET framework and Web services architecture. This methodology provides engineer-to-order (ETO) manufacturers with a distinct set of advantages when deploying the enterprise resource planning (ERP) application. VISIBILITY.net has a highly functional user interface, providing the user with a multi-document interface (multiple windows) in a single browser session.

Visibility extended the standard Microsoft ASP.NET development environment by providing a highly intuitive, interactive user experience that would not usually be possible within an Internet application. This accomplishment is achieved with a zero client interface. VISIBILITY.net does not download any software onto client PCs to operate. Any client PC with Internet Explorer 5.5 or later is capable of operating with VISIBILITY.net.

VISIBILITY.net is deployed as a true internet application - the system administrator need not know anything about the client hardware because no installation is necessary. In doing so it provides ubiquitous access for users inside the four walls of your organisation, for users at remote plants and sales offices, and for users 'on the road'.

* Internet Standards based - some ERP vendors have put a 'tick in the box' against industry standards such as HTTP, XML, .NET and Web services through the use of 'bolt-on' technology modules.

The very core of the VISIBILITY.NET application makes use of this technology today, without the need for additional middleware or integration applications. Read Full article here...

posted on Wednesday, March 15, 2006 11:01:19 AM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback
 Wednesday, February 15, 2006

Via windowsfordevices.com

McObject has released a C# implementation of a dual-licensed object-oriented embedded database that can be used to develop Window CE and Pocket PC applications. Originally written in Java, Perst boasts "tight integration" with C# and support for the .NET Compact Framework (CF), along with high performance and a modest footprint, the company says.

According to McObject, Perst's tight integration with C# results in "exceptional transparent persistence and ease in working with objects." The company adds that the database's typical 30 to 300 KB run-time code footprint enables it to satisfy the resource constraints of many embedded applications, and also makes it suitable for C# applications requiring high-speed data management.

Typical applications include mobile and embedded devices, industrial systems, Web services, and packaged software, according to the company.

In contrast to object/relational databases, or tools that provide object/relational mapping, Perst stores data directly in C# objects, McObject explains. This eliminates the need for expensive (in performance terms) run-time conversions between the database representation of the data and the C# representation, the company adds.

Additionally, "Perst ensures integrity via transactions that adhere to the ACID properties (Atomicity, Consistency, Isolation and Durability) with very fast recovery," McObject said.

Other Perst features include garbage collection, detection of hanging references, automatic schema evolution, XML import/export utilities, and master-slave replication support with the option to run read-only queries on slave nodes, according to McObject.

The company is offering Perst under a dual-license model. Users can download and modify the database source code and use it freely in non-commercial applications that are neither sold nor used internally by a business, and for which source code is made available. A commercial license is required when Perst-based software is sold or used for business, or if source code will be withheld, according to McObject.

posted on Wednesday, February 15, 2006 2:55:44 PM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback

I'm working on a  C# WinForm application in which I has to show a link and on click of that link, I wanted to show the website in browser window. I initially coded it as

 

System.Diagnostics.Process.Start("IExplore", URL);

 

This , though worked as desired, forced an IE instance to open and display the website, bypassing the user default browser settings. Kind of bugging for some users... Though not a rocket science, I found a neat implementation of retrieving the default browser executable name implementation of this on Ryan's blog on the link below..

 

http://ryanfarley.com/blog/archive/2004/05/16/649.aspx

 

Cheers!!

posted on Wednesday, February 15, 2006 2:43:59 PM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback
 Tuesday, January 31, 2006

Today, I was trapped in an interesting issue while  implementing a auto-complete URL dropdown in my new C# WinForm application. As in IE, I was able to select a url after it was visible in the dropdown but after selecting, enter press was just being ignored. (rather in IE, hitting enter enters the selected value in the box. I simply tried to implement KeyDown event for the ComboBox but to my despair, all the keys but "Enter" was being caught in the event by enter key wasn't invoking the event at all...

 

I went around Googling and it was not very late when I found the solution. and it was "Overriding IsInputKey  method to have Enter key handled. here is the code..

 

public class YourComboBox : ComboBox

{

            public YourComboBox() : base()

            {

            }

            /// <summary>

            /// Key Handler

            /// </summary>

            /// <param name="keyData"></param>

            protected override bool IsInputKey(Keys keyData)

            {

                        if (keyData == Keys.Enter)

                                    return true;

 

                        return base.IsInputKey (keyData);

            }

}

 

Now your Combo box should be driven from YourComboBox  and simply KeyDown event should be caught..(with little care)

 

 

private void yourComboBox1_KeyDown(object sender, KeyEventArgs e)

{

            if (e.KeyCode == Keys.Enter)

            {

                        e.Handled = true; //remember this line to tell base function that you handled the event already...

                        //Do something...

            }

}

 

 

This and you are all set...

 

Cheers!!

 

 

 

posted on Tuesday, January 31, 2006 12:43:23 PM (Central Standard Time, UTC-06:00)  #    Comments [3] Trackback
 Monday, January 16, 2006

I have recently moved my blog from community server to dasBlog. While setting up google Adsense ads on the site, I was caught up in a specific requirement as in where to put the ads. Google suggests that for high CTR ratio, ads should be placed just above the content and this left me searching for ways to put adsense in start of First Post's body content.

A simple way to implement this was modify your latest post every time you write a post ... cumbersome huh?? Not only cumbersome, this also invalidates your RSS as the feeds doesn't allow <_SCRIPT_> tag in the XML. Looked around little more thinking that I might not be the first one having this kinda requirement ...but to my disappointment, I couldn't find any such generic way to achieve this...

finally this is what I used as a workaround...I don't claim that this is the best possible way to do it but given my one day old relationship with with dasBlog code....this is the most generic change I could make to have it working for me...(Yes you read  it right...there is little code change in newtelligence.DasBlog.Web.Core.dll)..

here is what I did...

  1. First create a category named "AdPost" and add first post to it.
  2. Then modify site.config file to add one more element..Look closely for html tags converted to literals...

<InContentAdsense>
&lt;DIV style=&quot;PADDING-RIGHT: 5px; PADDING-LEFT: 5px; FLOAT: right; PADDING-BOTTOM: 5px;PADDING-TOP: 5px&quot;&gt;
&lt;SCRIPT type=text/javascript&gt;&lt;!--
google_ad_client = &quot;pub-123123123123123123&quot;;
google_alternate_color = &quot;FFFFFF&quot;;
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = &quot;300x250_as&quot;;
google_ad_type = &quot;text&quot;;
google_ad_channel =&quot;&quot;;
google_color_border = &quot;EEEEEE&quot;;
google_color_bg = &quot;FFFFFF&quot;;
google_color_link = &quot;355EA0&quot;;
google_color_url = &quot;355EA0&quot;;
google_color_text = &quot;333333&quot;;
//--&gt;
&lt;/SCRIPT&gt;
&lt;SCRIPT src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=text/javascript&gt;
&lt;/SCRIPT&gt; &lt;/DIV&gt;
</InContentAdsense>

Note: By this change there was some issues with configuration update page which I'll figure out later...

    3.  Set up thecodebase and add this code and declarition in SiteConfig.cs under project <b>newtelligence.DasBlog.Web.Core</b>


string inContentAdsense = null;   //to be added in declarition
public string InContentAdsense
 {
get { return inContentAdsense; }
set { inContentAdsense = value; }
}

      4. In the same project open Macros.cs and modify method ..public virtual Control Items{ ....}

         here is the modification....

string cntnt = entry.Content;
if (entry.Categories.IndexOf("AdPost") != -1)
{         
  entry.Content = requestPage.SiteConfig.InContentAdsense +  cntnt;
}
requestPage.ProcessItemTemplate(entry, itemPlaceHolder);
entry.Content = cntnt;

 

All this and you are ready to roll....Replace your web dll with this dll (newtelligence.DasBlog.Web.Core.dll) and place the config settings in right place.....Now in whichever post you wanna show Adsense, just add it to category  AdPost!!!! don't forget to reove other posts from AdPost category as google allowes only 3 instances of an add to be displayed!!!  On request I can forward you my copy of newtelligence.DasBlog.Web.Core.dll which would cover step 3 and 4.

Hope there would be a much streamlined solution provided for this in next version of dasBlog...

Cheers!!

 

posted on Monday, January 16, 2006 5:52:16 AM (Central Standard Time, UTC-06:00)  #    Comments [1] Trackback
 Wednesday, January 11, 2006
Microsoft announced a major win today in retails sector. Target Corporation, the national's second-largest discount general merchandise retailer, is headed to adopt Microsoft® .NET Framework based technologies within its 1,400 stores in 47 U.S. states. Target will migrate its systems within each store to the Microsoft .NET Framework 2.0, Windows Serveral 2003 and Microsoft SQL Server⢠2005, core technologies that deliver on the Microsoft Smarter Retailing strategy for connecting people, information, systems and devices.

According to Janet Schalk, chief information officer at Target Corporation, Microsoft technologies can help us drive down costs through a simplified architecture and easier-to-use development tools, These cost savings will enable us to invest in additional innovations that will enhance the store experience for our guests.

Microsoft provides technologies to Target in other key operational and customer-facing areas as well. This comes as a great example of Microsoft Smarter Retailing (http://www.microsoft.com/smartretail), an initiative designed to help retailers improve how they sell and operate. Read the full story here

posted on Wednesday, January 11, 2006 7:37:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback
 Monday, January 09, 2006

After un-installing SQL Server 2005 Beta version, I started facing issues with my SQL 2000 installation and it was shooting an strange error...

SQLDMO has not been registered, please re-run SQL Server setup and contact your system administrator”.

  After some analysis, i figured out that the issue was with SQLDMO.dll registration which went for a toss because of 2005 beta un-installation.  To fix the DMO try running this:

Regsvr32 [SQL folder Program Server]\80\Tools\Binn\SQLDMO.dll

This brakes the registration of SQL Server 2005 dll registration...so make sure you are doing this after un-installation of 2005 beta...

posted on Monday, January 09, 2006 6:03:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback