Aleksandar's computer workshop

Let's see what Aleksandar was fixing today.
My findings, tips & tricks related to computers, internet, programming and other stuff I was working with.

Health monitoring in ASP.NET 2.0

Here is a very simple web.config file that sends an e-mail whenever an unhandled error occurs. Pay attention to the <healthMonitoring> and <system.net> section. These are the important ones that makes it work.

 

<?xml version="1.0"?>
<configuration>
   <appSettings/>
   <connectionStrings/>

   <system.web>
      <compilation debug="false" />
      <trace enabled="true" localOnly="false" />

      <healthMonitoring enabled="true">
         <providers>
            <add name="EmailProvider" 
               type="System.Web.Management.SimpleMailWebEventProvider"
               from="you@domain.com"
               to="you@domain.com"
               subjectPrefix="Error: "
               buffer="true"
               bufferMode="Notification" />
         </providers>
         <rules>
            <add provider="EmailProvider" name="All App Events" eventName="All Errors" />
         </rules>
      </healthMonitoring>

   </system.web>
   <system.net>
      <mailSettings>
         <smtp from="you@domain.com">
            <network host="smtp.domain.com" />
         </smtp>
      </mailSettings>
   </system.net>
</configuration>

How easy can it get? Truly amazing.

http://blog.madskristensen.dk/post/Health-monitoring-in-ASPNET-20.aspx

http://aspnetresources.com/articles/aspnet_2_0_health_monitoring.aspx

http://msdn2.microsoft.com/en-us/library/ms998306.aspx

http://msdn2.microsoft.com/en-us/library/yc5yk01w.aspx

Properly Capturing Identity Values

When inserting a row into a database table that contains an identity column, I need a way to capture the identity value generated by the database engine after it inserts the row into this table. What can I use to capture this value while also making sure this value is accurate?

SQL Server provides three different functions for capturing the last generated identity value on a table that contains an identity column:
1) @@IDENTITY
2) SCOPE_IDENTITY()
3) IDENT_CURRENT(‘tablename’)

But which should you use? Check out this article for more information:
http://www.mssqltips.com/tip.asp?tip=1385