Friday, December 14, 2007

Let's count errors

Did you count how many mistakes developers of page made?
I found 4:
1) No custom error page.
2) They compiled and deployed ASP.NET project in Debug mode (had to deploy in Release mode).
3) They didn't set error notification by email and don't look into production error log. That's why this errors is hanging there for so long.
4) ProductDetail.aspx page cannot handle missing item.

Do they have any excuse for that?

Monday, August 13, 2007

Web site in production

Omar Al Zabir wrote great article about his experience dealing with web site production issues:
13 disasters for production web sites and their solutions

Web site in production

Omar Al Zabir has great article about his experience dealing with web site production issues:
13 disasters for production web sites and their solutions

Saturday, June 09, 2007

Why Common Bus projects fail

What is "Common Bus" project?

"Common Bus" project is such project which does not implement business requirements directly, but helps other projects to implement business requirements.

Examples of "Common Bus" projects:
1) Programming language.
2) Development environment.
3) Database management system (like Oracle or SQL Server).
4) COM (Component Object Model).

Reasons why Common Bus projects usually fail

1) Common Bus project is more abstract than regular projects.
More abstract means more complex.

2) When you design Common Bus project, you must not just understand Common Bus project itself, but also design or all business projects consuming Common Bus project.

3) It's harder to test abstract projects, because such projects don't have clear goals.

For example:
What are the goals of Development Environment project?
How would you test it?

It's hard to come up with test cases for "Common Bus" projects.

4) Because Common Bus project is hard to understand, development can easily go into wrong direction for months or even years unnoticed. That drains money from the budget and eats time.

Can Common Bus project be successful?

Implementing "Common bus" projects is possible, but it requires the following:
1) Very bright business analysts.
2) Very strong developers and architects.
3) Very strong testers.
4) Experience with developing similar "Common Bus" projects.
Note, that custom software development is considerably different from "Common Bus" software development.

I got Common Bus project. What do I do?

What to do if you are not good enough for "Common Bus" project, but
you have to do it anyway:
1) Simplify business requirements as much as possible.
2) Drop all "Common Bus" / "Abstract" requirements unless they are absolutely vital for your customer.
3) Build clear plan of how you are going to test your project.
Every test case must be easy to understand and test.
If you cannot come up with the set of clear test cases for your project -- that's quite reliable sign that your project is doomed. Find another project and cancel your Common Bus project ASAP.

Thursday, May 10, 2007

Receive and parse email in .NET

How to: Receive email through pop3 and parse mime message into From, To, Subject and Body parts

This task is not as trivial as it seemed to be.
1) .NET framework does not have classes which handle POP3
2) Email is sent in MIME format, which is quite tricky. In particular, email can have recursive attachments embedded into raw MIME email.

So far my research recommends two approaches:

Approach 1: Use an open source project.

It seems that the best open source MIME project is
LumiSoft .NET MIME parser.
You may browse all content here
Lumisoft Forum

Pop3 client retrieval & parsing sample
using(POP3_Client c = new POP3_Client()){

POP3_MessagesInfo mInf = c.GetMessagesInfo();

// Get first message if there is any
if(mInf.Count > 0){
byte[] messageData = c.GetMessage(mInf[0]);

// Parse message
Mime m = Mime.Parse(messageData);
string from = m.MainEntity.From;
string subject = m.MainEntity.Subject;
// ...

Approach 2: Buy a component

It seems that the best .NET Mime component available on the market so far is:
MIME4NET "True .Net Mime Parser".
The cost: $50

Tuesday, March 06, 2007

This report requires a default or user-defined value for the report parameter

I just spent couple of hours fighting "This report requires a default or user-defined value for the report parameter" error.
Report worked fine in report designer, but refused to properly render in serverReport.Render(...) method.

I tried Google Search and all voodoo magic, including:
- Renaming my parameter;
- Set default value for my parameter;
- Restarting VS.NET;
- Re-creating my report from scratch.
Nothing helped.
I even though about manual rebuilding OLAP cube in Analysis Server ...

But then I simply changed "Available values" [for my parameter] from "From query" to "Non-queried".

That helped.


Keywords: VS 2005, VS2005, Visual Studio .NET 2005, OLAP, Microsoft Reporting Services, Microsoft Analysis Services, Microsoft SQL Server 2005, C#, VB.NET.

Friday, February 23, 2007

Google Desktop can be hacked

This very interesting article explains in details how cross site scripting can be used to hack google desktop (if new version of Google desktop in not installed yet):

This demo shows how potential hacker can operate:
Demonstration of Google Desktop vulnerability

The article is pretty impressive and made me think about XSS vulnerability of my own web site.

Keywords: XSS, Web site security, javascript, hacker attack, XSS, RegEx, hack, Google Desktop.

Thursday, February 22, 2007

Geeks Rule and MBAs

Eric Sink (SourceGear) recommends to start software company with developers only.
Geeks Rule and MBAs Drool

It is common to see software companies starting out with two founders, a geek and an MBA. Do you really need the MBA?

If I were to oversimplify the message of this article, I would make two statements:

Developers add more value to a software company than anybody else.
The truth of statement 1 is inversely correlated with the size of the company.
When a company is very small or just getting started, nobody can add value as well as a developer because there isn't really much other stuff that needs to be done. You don't have customers yet.

Thursday, January 25, 2007

Health Monitoring in ASP.NET 2.0

Health Monitoring in ASP.NET 2.0 helps monitor problems in your application. Here's nice MSDN article about it:
How To: Use Health Monitoring in ASP.NET 2.0
In particular,
System.Web.Management.SqlWebEventProvider works quite good out of the box.

Note, that Health Monitoring designed for web forms applications and does not target winforms applications.
For example, if you want logging Windows Services, Log4Net 3rd party component, or through embedded System.Diagnostics.EventLog component are the ways to go.

If you want to get error messages from your site through email, read this:
How to: Send E-mail for Health Monitoring Notifications

Note, however, that SimpleMailWebEventProvider has some unpleasant limitations:
1) You cannot send emails using SSL SMTP, so Gmail's SMTP is not available for you. The reason here is that uses standard SMTP ASP.NET provider, and standard SMTP ASP.NET provider is not fully configurable through web.config.
There is no way for you to specify:
smtpClient.EnableSsl = true;
As a result, emails sent through Google's SMTP are simply dissappear.

2) You cannot override SimpleMailWebEventProvider provider, because it's sealed.
So, you have to write your own mail provider from scratch.

Implementing your own isn't very hard.
I tried to inherit my EmailEventProvider from MailWebEventProvider, but I couldn't even make the code compile. It seems that MailWebEventProvider if poorly written (yeap, not every developer at MS is good).

But inheriting from BufferedWebEventProvider worked like a charm.
Here's the C# code:
using System;
using System.Text;
using System.Web;
using System.Web.Management;
using System.Configuration;
using System.Collections.Specialized;

namespace MyNameSpace
sealed class EmailEventProvider : BufferedWebEventProvider
private string _to;
private string _subject;

public override void Initialize(string name, NameValueCollection config)
GetAndRemoveStringAttribute(config, "to", ref this._to);
GetAndRemoveStringAttribute(config, "subject", ref this._subject);
if (string.IsNullOrEmpty(this._to))
throw new ConfigurationErrorsException(string.Format("Recipient must be defined for {0}provider", name));
base.Initialize(name, config);

private static void GetAndRemoveStringAttribute(NameValueCollection config, string attrib, ref string val)
val = config.Get(attrib);

public override void ProcessEventFlush(WebEventBufferFlushInfo flushInfo)
StringBuilder sb = new StringBuilder();
// Write flushInfo.Events:
foreach (WebBaseEvent wbe in flushInfo.Events)
sb.AppendFormat("{0}\r\n", wbe.ToString(true, true));

SendMail(DateTime.Now.ToString(), _to, _subject, sb.ToString());

Here's web.config's code:
<healthMonitoring enabled="true" heartbeatInterval="0" >
    <add name="MyEmailEventProvider" type="MyNameSpace.EmailEventProvider" buffer="false"
         subject="Crash in MyAspNet app" />
    <add name="All Errors by Email" eventName="All Errors" provider="MyEmailEventProvider" />


About Me

My photo
Email me: