Wednesday, October 26, 2011

What is IoC

http://martinfowler.com/articles/injection.html#InversionOfControl

The Downsides of ASP.NET Session State

http://tech-journals.com/jonow/2011/10/22/the-downsides-of-asp-net-session-state

by default the ASP.NET pipeline will not process requests belonging to the same session concurrently. It serialises them, i.e. it queues them in the order that they were received so that they are processed serially rather than in parallel. 

Monday, October 24, 2011

Wednesday, October 19, 2011

How to solve problem, "Team Foundation Services are not available from server 503"


One reason to cause this problem is the user account :TFSSERVICE, either locked or password expired.

In the event log, you will got following error event:

Application pool Microsoft Team Foundation Server Application Pool has been disabled. Windows Process Activation Service (WAS) encountered a failure when it started a worker process to serve the application pool.


Solution:
1. Open Team Foundation Server admin console, find the action, "reapply the account", and input password again.
2. Reset IIS server

Prevent ASP.NET cookies from being sent on every css, js, image request

http://omaralzabir.com/prevent-asp-net-cookies-from-being-sent-on-every-css-js-image-request/

Thursday, October 13, 2011

Indexes causes deadlocks in SQL Server



Another common scenario for deadlock
If make a lot of indexes with same set of columns but sequence is different, can cause deadlocks between select/update query.
Solution:
Carefully design indexes for a table, don’t let tuning advisor do it for you.

Reference:




ASP.NET MVC - Html.Partial vs Html.RenderPartial

http://info.titodotnet.com/2011/10/aspnet-mvc-htmlpartial-vs.html

stream.js, a Javascript lib provides data structure for infinite number of elements

http://streamjs.org/

Wednesday, October 12, 2011

Using TRY - CATCH to Rollback a Transaction - SQL Server

http://www.eggheadcafe.com/tutorials/aspnet/6a8ef7d5-840e-4629-b53a-1a40e7db601f/using-try--catch-to-rollback-a-transaction--sql-server.aspx


BEGIN
BEGIN TRY --Start the Try Block..
BEGIN TRANSACTION -- Start the transaction..
UPDATE MyChecking SET Amount = Amount - @Amount
WHERE AccountNum = @AccountNum
UPDATE MySavings SET Amount = Amount + @Amount
WHERE AccountNum = @AccountNum
COMMIT TRAN -- Transaction Success!
END TRY
BEGIN CATCH


ROLLBACK TRAN --RollBack in case of Error
-- you can Raise ERROR with RAISEERROR() Statement including the details of the exception
RAISERROR(ERROR_MESSAGE(), ERROR_SEVERITY(), 1)
END CATCH
END

Globalization And Localization With Razor Web Pages

http://www.mikesdotnetting.com/Article/183/Globalization-And-Localization-With-Razor-Web-Pages

How to check variable is undefined in Javascript


            if (typeof (variablename) == "undefined") {
            }

Friday, October 7, 2011

How to analyze and fix deadlocks in SQL Server?

1.Monitor and get detail on each deadlock
Analyzing Deadlocks with SQL Server Profiler
http://msdn.microsoft.com/en-us/library/ms188246.aspx


2. Wrap all all of insert/update/delete into transaction with rollback and high deadlock priority
SET DEADLOCK_PRIORITY HIGH;
http://msdn.microsoft.com/en-us/library/ms186736.aspx

SET XACT_ABORT ON;
http://msdn.microsoft.com/en-us/library/ms188792.aspx

3. Improve all of slow SQL query that got from xdl file

Tuesday, October 4, 2011

Two useful javascript methods: preventDefault, stopPropagation


event.preventDefault
Cancels the event if it is cancelable, without stopping further propagation of the event

event.stopPropagation