asp.net, you need to communicate more

June 24, 2008 under AJAX, ASMX, ASP.NET, Uncategorized, Web Services

The topics I’ve been posting about lately have been somewhat varied; from Internet culture to hockey to politics to random thoughts. Remember when I went on and on about programming? Me too, so here goes.

This is for any ASP.NET coders out there Google-ing “There was an error processing the request”. I recently came across this issue, so I wanted to share what I’ve found to resolve it. You’ve probably written an awesome web service with public methods that do awesome things and are so meticulously coded so as to adhere to all the hip programming concepts and best practices. I’d bet that you’re doing the right thing in your web service’s public methods by capturing code that’s prone to throwing exceptions like this:

namespace FooService
{
    [WebMethod(EnableSession=true)]
    public void Foo()
    {
        try
        {
            // Dangerous method alert
            MyWildMethod();
        }
        catch (Exception ex)
        {
            // Handle with grace.
            CleanupWildMethod();

            throw new Exception("Something happened - no worries.");
        }
    }
}

Perhaps you’re calling this web service method via AJAX on your presentation layer pages and expecting this to come back in get_message():

function UseMyWebService()
{
    FooService.Foo(SuccessCallback, ErrorCallback);
}
 
function ErrorCallback(error)
{
    alert('Whoa: ' + error.get_message());
}

And it does in your development environment. Then you deploy this to production and your lovely and friendly “Something happened…no worries” message turns into the user-unfriendly “There was an error processing the request” message. What gives?

There’s a good chance that you’re using custom error pages in your project. Your Web.config might have something like this in it:

<customerrors mode="On">
      <error statusCode="403" redirect="~/error.aspx?eid=403" />
      <error statusCode="500" redirect="~/error.aspx?eid=500" />
      <error statusCode="501" redirect="~/error.aspx?eid=501" />
      <error statusCode="502" redirect="~/error.aspx?eid=502" />
</customerrors>

If you do, you’ve successfully determined that users should see friendly error pages rather than cryptic ones that only programmers would understand. Unfortunately, Microsoft hasn’t figured this out yet and instead of allowing the user-friendly message in your exception to propagate back, they replace it with “There was an error processing the request”. There is a solution. You could set the customErrors mode to “Off”, but that would defeat the purpose. Instead, ensure that your web service ASMX files are in a folder of their own. Then, inside of that folder, create a basic Web.config that looks like this:

< ?xml version="1.0"?>

<configuration>
    <appsettings />
    <connectionstrings />
    <system .web>
      <customerrors mode="Off" />
    </system>
</configuration>

That’s all it takes to correct this oversight on Microsoft’s part.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 » tags: , , ,

download day 2008

June 17, 2008 under Download Day 2008, Firefox, Mozilla

Today has been christened Download Day 2008 by the Mozilla Organization. You can do your part by downloading Firefox 3.0 today in order to help set a World Record for the most software downloads within 24 hours. Don’t forget to tell your friends, family and colleagues to do the same. The Firefox developers have done some amazing work, especially regarding memory usage; it’s crazy fast.

Download Day 2008

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

i sha’n’t miss my student loan

June 10, 2008 under Student Loan

I’ve dreamt of this day for so long, now that it’s here, I’m not sure what to say other than “wooohooo, no more student loan!!!”

Always having to be different, when my contemporaries from O’Gorman High School‘s class of 1995 who were off to university were filling out OSAP forms, I was applying for a Canada Student Loan. Why? Because I wasn’t attending a university in Ontario, but one in the United States instead. If it weren’t for meeting my wife in university, going to the US for my post-secondary education can be considered a stupid idea with the increased cost and the horrible exchange rate at the time. By the time I had graduated in December of 1999 with my Computer Science degree, I had $74 to my name and faced a debt of over $26,000 owing to the Royal Bank.

It may seem strange that my student loan was through a bank, rather than directly through the federal government. That’s one of the joys of the Canada Student Loan. In what seems like a punishment for leaving the country for education, I had to do all of my loan dealings thorough a bank. For whatever reason, my bank wasn’t on the list of approved banks for Canada Student Loans. My choices were the Royal Bank and CIBC. My reason for going with the Royal was due to the fact that it was closer to my parents’ house in Timmins for me to go to the Royal Bank branch in the 101 Mall than to go up two more blocks on Pine Street to get to the CIBC; brilliant logic, I know.

To add insult to injury, the Royal Bank slapped an 8.5% interest rate on my student loan, and repayment began June 1, 2000. I wasn’t making much money at that time. I had to take the first job offer that I got, since the Dot-Com Bubble was bursting and not a lot of hiring was going on. While it’s fair to say that a post-secondary education is an investment with short-term pain that (hopefully) yields long-term gain, facing more than $26,000 in debt that’s going to get worse by 8.5% each month when you have no money and aren’t earning very much is a very scary thing when you’re starting your career. So I’ve found that burying the monster that was my student loan debt was extremely satisfying.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 » tags: ,

now what will i watch in high definition?

June 5, 2008 under Hockey, NHL playoffs

Experience is apparently the difference-maker and is probably a prime factor in the Red Wings‘ Stanley Cup victory. Whenever possible in the series, the old men from Detroit took early leads and then sat back and played safe and boring (but effective) hockey. It clearly frustrated the (normally) high-flying run ‘n’ gun youngsters from Pittsburgh. This win also marks a couple of firsts; Lidstrom becomes the first European-born captain to lead his team to a Cup and Cleary will be the first Newfoundlander to have the opportunity to bring Stanley to “The Rock”.

I guess the city of Detroit might benefit from this as well. As one of my former roommates from university pointed out:

its very tough economic times( Michigan is ranked the second worst state next to Louisiana) and a city mayor under perjury charges. This state and the city of Detroit needs a very positive thing

While I don’t know of any statistical data that backs that up, it’s obvious that Detroit is very much becoming a ghost town, and there were a lot of empty seats in Detroit during this year’s playoffs.

You have to give the Pens some credit, though. Their pluckiness almost made up for their lack of experience.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
comments: 0 »