Home
>
Archive
>
SSW Standards
>
Rules
>
SSW Rules to Better ASP.NET
There was an error displaying the testimonials. Please
report this error
to SSW and include the following text:
- A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and
that SQL Server is configured to allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a
connection to SQL Server)
Do you agree with them all? Are we missing some?
Let us know
what you think.
-
Do you know to add Output Caching to menus?
It's not just menus; all static content should have Caching set.
This is especially important if your static content is built from
data that rarely changes.
<%@OutputCache Duration="900" Shared="true" VaryByParam="None" %>
Figure: make sure you always add output caching
-
Do you know to check performance?
In order to make sure you have not done something silly that will
kill your website it is worth checking to see what the worst
performing pages are on your site.
In order to do this download Log Parser 2.2 and run this command:
logparser "select top 10 cs-uri-stem, time-taken from INSERT_YOUR_IIS_LOG_FILE_NAME.log group by cs-uri-stem order by time-taken desc" -q:on
Figure: -Log parser command to fin top 10 bad pages
This will list the top 10 worst preforming pages on your site.
/Home/catalog/searchresults.aspx 363015
/Home/catalog/searchresults.aspx 316234
/Home/catalog/searchresults.aspx 226375
/Home/Cars.aspx 221296
/Home/images/t/34-60684_StandardImage.image.ashx 131937
/Home/Vans.aspx 127281
/Home/Bikes.aspx 114750
/Home/catalog/searchresults.aspx 89375
/Home/images/t/34-4220_StandardImage.image.ashx 81453
/Home/ScriptResource.axd 79609
Figure: Both the Search pages and the product pages are performing
badly
Note: You may need to check
IIS and Asp.Net hanging or poor performance
if you are having real time problems.
-
Do you know to avoid the double bind?
In the good old days before Web 2.0 (Asynchronous web) you could
get away with checking for IsPostBack alone to determine if you
should bind the data. Now you need to check IsCallback as well.
protected void Page_PreRender(object sender, EventArgs e)
{
BindData(!this.IsPostBack);
}
Figure: Bad example – this code will still fire on a Async
call
protected void Page_PreRender(object sender, EventArgs e)
{
BindData(!this.IsPostBack || !this.IsCallback);
}
Figure: Good example – this code will now not fire on Aync
calls
Acknowledgments
Martin Hinshelwood