Wednesday, November 12, 2008

Optimizing Your Aspnet Pages For Faster Loading And Better Performance

Writen by John Belthoff

If you read the internet and 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.

Let's say you have a page that displays articles based on a query string. Take my article pages for instance. Each article is stored in a database and displayed on the page based on the unique id of the article as stored in the database.

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.

Happy Programming!

John Belthoff is an avid web developer who writes about Asp.Net in his spare time. He owns a Windows Asp.Net, Asp Web Hosting Company where you can contact him about hosting your website/blog or just to learn more.

Tuesday, November 11, 2008

How To Quality Review Your Website

Writen by Dan Moore

Once your website is up and running, it is important to review and update the web site from time to time. This will ensure that you keep the content fresh and relevant, and of course can also make changes to improve the content in the light of feedback and experience gleamed through running the site.

A professional review will run through various aspects of your site - here is a brief outline of the areas that should be examined during a web site review:

Usability
This is simply how easy the site is to use. A formal test may involve the preparation of a script containing simple and not so simple tasks for the uninitiated and experienced customer alike to perform. The results are an excellent measure of how usable your site is. If you find that all customers just cannot find an important area of your site for instance, then you can take measures to redress the balance.

Taxonomy
Related to usability, the hierarchy and structure of your site may change in light of feedback received, learnings and different internal or marketing priorities. The key is to remember to structure your site to fit external or customer perceptions and understanding of your company. A common mistake is to structure a site along internal divisions which is likely to confuse a customer who is not going to know the internal structure and politics of a company!

Accessibility
A key requirement: can anyone view your site no matter what web browser or monitor they use? If they are using a text-to-speech browser for instance, or have images and JavaScript switched off - can they still effectively move through and understand your site? Accessibility is key and there may also be legal obligations, depending which country you are in, for your site to conform to accessibility standards.

Search engine positioning
A review to examine the search engine ranking of a site for various common searches related to your business, and to provide recommendations as to what could be done to improve your search engine presence - and hence drive more traffic to your site.

Traffic review
It is very important to measure traffic to your site, where it comes from, and whether it is traffic from the sources you would most expect. You should inspect whether strategic linkings or partnerships are working for you, and what searches people are actually performing to reach your site. Crucially - what can be done to drive even more traffic to your site?

Content review
The content should be reviewed to ensure that it is clear, to the point and of course up-to-date. As promotions finish or expire and new ones come along you should ensure that the dead wood is cut out and replaced with fresh and relevant content.

Dan Moore is Director of Clarity Media Limited, a web design company and puzzle supplier of such smash hit puzzles as sudoku, kakuro, hanjie and codewords

Monday, November 10, 2008

Market Your Storefront With A Website

Writen by Mary Rita Earle

Many people think that the Internet offers a tremendous marketplace, while others will question the extra effort and money to purchase and design a website. Some of the money-making values of having a website are summarized in the following paragraphs for your consideration.

1. If you have a local group of customers and want to expand to the neighboring areas, states or even, countries, without spending massive amounts of costly advertising money or even leasing more company space, then the Internet can work very well for you. Niche markets (small groups of customers scattered about that are interested in a very specific item or service) also work very well on the Internet.

2. As a business owner, you need to provide a map and directions to your store for your customers and enable them to look up specials, discounts, limited merchandise, or varieties and prices of each item you market. For instance, let's say you sell cheesecakes and you would like to spend less time on the phone explaining the different varieties, how many people the different varieties will serve, prices, and availability. Here's how this could work online for you. You would provide a secure, encrypted order form thereby collecting the person's credit information as well as their address, phone, and email information. They would list their preferences as to varieties and sizes of cheesecakes. This form would be sent directly to your email or to your fax so that you would have the items ready for the customer to pick up that day or the day they designate. You would have the cheesecakes shipped for those that cannot make it to your store. When a customer returns to order another product from your website, they would not have to fill out most of the form as it would already be in your database.

3. You build their confidence when you show customers that you have their best interest and shopping convenience in mind when you open a website and properly maintain that website with new and updated information. Customers will appreciate being able to read about the owners, the store's policies, the service after the sale, and any other items you think would develop a rapport to allow them to do more business with you. Having a website allows your company to develop its style and branding and develops a sense of security for the customers in doing business with your firm.

4. A small operation can look just as important as a large corporation. A website builds confidence and value into your products and services and allows you to receive orders you may have missed without being on the Internet.

5. If you do advertising on the radio or TV, newspapers or direct mail, having a website gives the customer a place to review what you tell them in the ads in much more detail. Every ad should reference your website so customers can view the details at a time and place that is convenient 24 hours a day seven days a week. You can quickly change and update information on a website without the expense of printed materials.

6. You can do any promotion online that you can do offline and much cheaper. Coupons, money-off sales, discounts, employee recognition, limited merchandise you want to move, all these can be marketed on your website. Keeping the website up-to-date can be provided by your webmaster at a very nominal fee.

I hope that you can see from some of the above points that having your own website is necessary in today's marketplace for any small or medium-sized business as well as any at-home business. Customers are out there looking for you and you need to take advantage of where they are looking and, right now, that is the INTERNET! Since your competitors have a website, they are perceived as being more up-to-date. The ease, convenience, special online savings, information about your company's mission, your services, your ability to communicate with customers are all important reasons for having a dynamic online website. Online marketing will only continue to grow...WILL YOUR CUSTOMERS FIND YOU ONLINE?

Mary Rita Earle is the owner of http://www.duchessr.biz Duchess Marketing. A complete suite of the hottest work at home ideas, opportunities, tips and tools for the home business entrepreneur. Stop by and signup for her free Home Biz Tips newsletter!

Sunday, November 9, 2008

The Importance Of Monitoring Your Website

Writen by Douglas Titchmarsh

Are you monitoring your website?

You should be, especially if you are using it to make some extra cash, and definitely if it is your only source of income.

You need to monitor your website to protect it from so many nasties which could affect your bottom line. Any of the following could bring your site to a close.

A hack attack

If your website is hacked, it could be used for any number of illegal activities. A hacker could use your hosting account to send uce (Spam) from your domain or even add web pages such as user information "phishing" sites. These sites will have a page which looks like a login page for Paypal, Ebay or any bank. If someone fills in the form their details are sent to the hacker who now has access to their account. Your website will be shut down, and you lose money while you sort out the mess.

If you have any user information stored on your websites server, a hacker may also gain access to that too, and personal information is a very easy commodity to sell on.

Keep an eye on your site for any unexpected activity or unusual stats showing for pages you didn't make yourself. Most accounts have some kind of statistics built in to the control panel so it shouldn't cost too much to monitor visits and hits, and to which pages they go. Make sure any scripts you use are secure and updated with any patches to keep the hackers out too.

Hosting or server problems

Your host, or server may have a problem, and lose access to the internet, or crash taking all sites hosted there down with them.

This gives you two potential headaches, firstly loss of business while it is offline, but more importantly you may lose data. Making sure you take regular backups of all databases, and all your sites pages will help, also monitoring how often any outages occur, and how long each lasts will tell you whether it's time to change hosts.

No host can guarantee with absolute certainty 100% uptime, but some are much more prone to downtime than others. If you have all the site information backed up, moving hosts isn't as much of a task as it used to be, and can be done in quite a short time if needed. As hosting is such a cut throat business, finding a new one is also relatively simple. There are even software programs which will alert you if your site is unavailable.

Blog and Forum spamming

With the all pervasive spread of blogging it was inevitable that some people would resort to spamming them. Forums and message boards are also open to abuse from software which will autopost to thousands of sites in minutes.

If your blog is able to accept comments, it is wise to ask for some kind of registration from people who wish to make comments. If you don't ask for registration you leave your blog open to blatant advertising done by software, which will be unlikely to bear any relevance to your blogs subject. This goes for your forums too, allowing guests to post without registration is open to abuse by widely available software which autoposts inane comments with a signature which contains a url to the spammers product.

Asking for registration will help ensure that only people committed to posting something relevant get to add their comments or posts. If someone wants to post they will take the time to register.

It may take a little time, but monitoring your websites could save you from a lot more wasted time in the future. Backups of your site will help and should be taken at least weekly, and all your scripts should at least have security updates as soon as they are released.

It's your site, make sure it stays in your control.

Douglas Titchmarsh also authors two ezines avaialable at http://www.cashinonline.info/subscribe.htm and http://www.thediscountebookstore.com/blog