______________________________________________________________________
Tip of the Day!
Guidelines For Rendering Grid Data
· Avoid using inline code.
· Avoid using Response.Write from the Page_Load event in the code-behind class.
· Do not use the concatenation operators when building strings iteratively. Always use
the StringBuilder class.
· Avoid using server-side table objects when building tables with large numbers of rows.
· Avoid using the Repeater control for building grids.
· If you use the Repeater Control, use the DataBinder.Eval method to extract values from
the DataSource.
______________________________________________________________________
Tip of the Day!
Guidelines For DataReaders
· Don't use CommandBehavior.SequentialAccess with the ExecuteReader method unless you are
accessing a large amount of blob data in each row.
· Don't bother trying to use the specific typed accessor methods or a DataReader if you are
building up a string. Only use them when you need to interact with the data in the native type.
______________________________________________________________________
Tip of the Day!
Guidelines For Creating Controls
· If you have time during development or you need to share a control across multiple
projects, create a custom control. This will give perform on a par with running code
directly in the web form code-behind.
· If you need to rapidly create a grid control that will be used only within a single
project then create a User Control.
· Don't create generic classes that return large strings.
______________________________________________________________________
Tip of the Day!
Code Location Guidelines
· Always place page logic within the code behind class, not within script blocks in the HTML
portion of the page.
· Use Classes to encapsulate business logic only when that logic must be shared across more
than one page.
______________________________________________________________________
Tip of the Day!
Guidelines for Releasing
Always set the debug attribute of the compilation element in the web.config file to "false"
before releasing an application to production.
______________________________________________________________________
Tip of the Day!
Guidelines for Option Strict
If you don't mind being nagged by the compiler at design-time to explicitly cast your variable
assignments, then set Option Strict to On to gain a small performance boost and help your code
avoid unforeseen errors.
______________________________________________________________________
Tip of the Day!
Guidelines for Session State
· For a small performance gain, disable the Session State at either the page or application level.
· Definitely disable page level Session State for pages not requiring the Session when using
an external Session resource, such as SQL Server.
______________________________________________________________________
Tip of the Day!
Do not access user controls programmatically with a cache directive
Do not access user controls programmatically with a cache directive. If the control is
found in the cache, the runtime will not instantiate the user control, so you won't be able
to access it and an exception will be generated.
______________________________________________________________________
Tip of the Day!
Use fragment caching to speed up the common elements in your application
Use fragment caching to speed up the common elements in your application, such as menus and
navigation bars, by creating user controls and caching those. VaryByControl will vary the
cache based on the value of the web server controls in the user control.
______________________________________________________________________
Tip of the Day!
You can cache the response for a Web Form request
You can cache the response for a Web Form request. Be careful when using the VaryByParam
attribute if there are a lot of parameters with a lot of options, as you could end up caching
far too much. You can also use VaryByCustom when you want to vary the cache based on something
that isn't a parameter.
______________________________________________________________________
Tip of the Day!
Cache anything that won't change too often
Cache where possible anything that won't change too often, and which otherwise you would
have to keep reading from disk.
______________________________________________________________________
Tip of the Day!
Use weak references when you have an object that you'd like to keep, but that you don't mind if
the garbage collector decides it needs the memory for something else
Use weak references whenever you have an object that you'd like to keep around as long as you
can, but that you don't mind if the garbage collector decides it needs the memory for something
else. This way you don't have to keep it open at the expense of other functionality, nor do you
have to explicitly throw it away and create a new one every so often.
______________________________________________________________________
Tip of the Day!
Use Jagged Arrays
Jagged arrays provide savings in memory and performance over multidimensional arrays.
______________________________________________________________________
Tip of the Day!
Use exceptions wisely
Use exceptions wisely. Exception handling is cheap, but actual exceptions come at a cost.
Only throw exceptions if the situation is actually exceptional. In other situations,
consider alternative methods of handling the situation.
______________________________________________________________________
Tip of the Day!
Expose an object's data fields as properties
Exposing an object's data fields as properties lets us delay computation until the
information is really needed.
______________________________________________________________________
Tip of the Day!
Using VBScript to check whether Acrobat Reader is installed on a client's system
This tip uses VBScript to check whether Acrobat Reader is installed on a client's system or not:
______________________________________________________________________
Tip of the Day!
Authentication for Intranets
Forms based authentication is an independent authentication method that
works equally well for local and remote users of anintranet, since
login information is requested from the user as part of the web
application.
Windows integrated authentication involves tying intranet
authentication in with existing network accounts. This is great for local network
intranets, since users only need to log on once, when they log on to
their Windows domain account. The account information is then passed on to
the intranet code when they access the site, so that they don't need to
enter additional information. This has the effect of streamlining
things, and makes the intranet feel more like a corporate application. The
main benefit is that all user account information is centralized.
______________________________________________________________________
Tip of the Day!
IBuySpy Portal Downloads
There are four different versions of the download for IBuySpy Portal, two for the VB.NET version
of the code and two for the C# version. The difference between the two versions is that one of
them (the VS.NET version) is intended for Visual Studio .NET users while the other (the SDK
version) isn't. There is no difference in functionality between these versions, only that the
VS.NET version uses the "code-behind" model for all ASP.NET files, where the code is contained
in separate files rather than being included in .aspx and .ascx files, and includes solution
files for loading straight into the VS.NET IDE.
______________________________________________________________________
Tip of the Day!
Identify common tasks and package them into re-usable components
Identifying common tasks and packaging them into re-usable components at the early stage of
an intranet implementation is very important to cut the implementation time and improve
manageability.
______________________________________________________________________
Tip of the Day!
GDI+
GDI+ derives its name from its predecessor, the Graphics Device Interface or GDI that allows
you to display graphical output on the screen, printer, or on a bitmap in a memory too.
GDI+ as a set of classes (gdiplus.dll) written in C++ is a subsystem of the Microsoft Windows XP
and Windows .NET Server operating systems and can be used both in managed and unmanaged code.
______________________________________________________________________
Tip of the Day!
Don't store more session state information than you need
Don't store more session state information than you need; excessive use
of state storage can impact scalability.
Today’s tip is taken from Professional ASP.NET Performance
(http://www.wrox.com/books/1861007558.htm)
______________________________________________________________________
Tip of the Day!
Minimize the number of server-side controls
Minimize the number of server-side controls. Server controls use not only view state, but also
have their own associated processing costs.
Today’s tip is taken from Professional ASP.NET Performance
(http://www.wrox.com/books/1861007558.htm)
______________________________________________________________________
Tip of the Day!
Turn off view state
Turn off view state for controls that you don't need persisted during a postback.
Turn view state on for entire pages if they will never be used to post back.
______________________________________________________________________
Tip of the Day!
Remove the guest user account from IBuySpy
The guest user account included with IBuySpy has the password 'guest' and is part of the Admins
role, thereby having the highest level of security permissions. Given the generic nature of this
account, it should be eliminated to prevent unauthorized access to the portal.
If you still want to have a guest account for your portal, you should at least remove it from
the Admins role, and assign it minimum permissions required to access the desired resources in
the portal.
Removing or altering the guest account is one of the first things that should be done after
installing an IBuySpy application. Leaving it in place leaves a huge security hole.
Today’s tip is taken from Building an ASP.NET Intranet http://www.wrox.com/books/1861007493.htm)
______________________________________________________________________
Tip of the Day!
Using Enterprise Manager with MSDE
If you only have MSDE installed then many administration tasks may only be carried out
using command line SQL queries. Here's a tip: get the Enterprise Manager application from
the MSDN SQL Server evaluation download - it'll make your life a lot easier and isn't
limited by the 120 day trial license that applies to the SQL Server database download itself!
______________________________________________________________________
Tip of the Day!
Context Switch
The process of shifting between threads is known as a "context switch".
A context switch occurs when the details and "state" of the old thread is
swapped for the new thread (which will have a small proportion of the processors time).
______________________________________________________________________
Tip of the Day!
JIT and gc optimization
The JIT compiler and garbage collector perform a number of
optimizations, which means that you don't have to. Trying to out-think the
framework will rarely result in any performance gain.
______________________________________________________________________
Tip of the Day!
Be wary of doing too much performance tracking
It should be remembered that the more in-depth the tracking of performance, the more that
the performance is altered by performing such tracking.
______________________________________________________________________
Tip of the Day!
Don’t prefix the name of your stored procedures with sp_
System stored procedures in SQL Server begin with sp_. If your stored procedures also
begin with the same three letters as the system defined ones, then rather than being
found in the portion of the database allocated to user-defined procedures, and executed
immediately, the system will first look through all of the system defined ones to see if
it exists. This will cause a minor slowdown, but as it is done on every single table there
is no need to suffer this overhead for the sake of a slight modification to naming conventions.
As a further benefit, using a different naming convention will also help developers distinguish
between custom functionality for the application being developed, and standard functionality
provided by the underlying system.
______________________________________________________________________
Tip of the Day!
Performance counters only retain data for as long as there is a reference to the counter
Performance counters do not store performance data like an event log, or an entry in a database.
A performance counter will only retain data for as long as there is a reference to the counter.
When the last reference to a counter ends, the counter is reset to 0. While we can use logging
and trend analysis to get a good idea of performance over a period of time, a performance counter
is designed to record only while active.
______________________________________________________________________
Tip of the Day!
Enabling smart navigation for an entire web site
You can enable smart navigation for an entire web site by using the 'smartNavigation'
property of the "pages" setting in the web site’s web.config file. You can also specify
it as the default for all web sites on a particular machine by setting the same value
in the machine.config settings file:
"); //System.Environment Class
Response.Write (Server.MachineName+"
"); //HttpServerUtility class
Response.Write (System.Net.Dns.GetHostName()+"
"); //System.Net.Dns Class
}
______________________________________________________________________
Tip of the Day!
New Improved Image Swap
On 5th November we published an image swapping tip. ASPToday reader Krishna Tummala has
supplied a more elegant solution (that is a third the size) that has the same functionality: