September 2010 - Posts

ASP.NET Security Vulnerability (1.0 - 4.0)

It's very important, check it out if you haven't take any action yet:

  • http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx
  • http://www.microsoft.com/technet/security/advisory/2416728.mspx 
  • http://weblogs.asp.net/scottgu/archive/2010/09/20/frequently-asked-questions-about-the-asp-net-security-vulnerability.aspx
<configuration>
  <system.web>
    <customErrors mode="On" defaultRedirect="~/error.html" />
  </system.web>
</configuration>
Posted by Colt | with no comments
Filed under:

EventSource and EventLog.WriteEntry

It's pretty easy to write an entry into Windows event log in ASP.NET

For example, EventLog.WriteEntry("AppName", YourMessage, EventLogEntryType.Error)

However, if you don't have sufficient rights and create the event source in advance

For example, 

if (! EventLog.SourceExists("AppName"))
      EventLog.CreateEventSource("AppName", "AppName");

Alternatively, you can create the event source manually via RegEdit by adding a new key at:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application

Posted by Colt | with no comments
Filed under:

List all tables and their row counts

Just find few useful tips/tool when I try to compare the schema and content of two SQL databases:

  1. DBComparer (free)
  2. Find out DB lock: select distinct object_name(a.rsc_objid), a.req_spid, b.loginame from master.dbo.syslockinfo a (nolock) join master.dbo.sysprocesses b (nolock) on a.req_spid=b.spid where object_name(a.rsc_objid) is not null
  3. List all tables in database: SELECT * FROM sys.Tables
  4. List all tables and their row counts
SELECT 
    [TableName] = so.name, 
    [RowCount] = MAX(si.rows) 
FROM 
    sysobjects so, 
    sysindexes si 
WHERE 
    so.xtype = 'U' 
    AND 
    si.id = OBJECT_ID(so.name) 
GROUP BY 
    so.name 
ORDER BY 
    2 DESC
Posted by Colt | 3 comment(s)
Filed under:
More Posts