/// <summary>
/// Returns an anchor element (a element) that contains
/// the virtual path of the specified area action.
/// </summary>
/// <param name="helper">The HTML helper instance that this method extends.</param>
/// <param name="linkText">The inner text of the anchor element.</param>
/// <param name="actionName">The name of the action.</param>
/// <param name="controllerName">The name of the controller.</param>
/// <param name="areaName">The name of the area.</param>
/// <returns></returns>
public static MvcHtmlString ActionLink(
this HtmlHelper helper,
string linkText,
string actionName,
string controllerName,
string areaName)
{
return helper.ActionLink(
linkText,
actionName,
controllerName,
areaName,
null);
}
/// <summary>
/// Returns an anchor element (a element) that contains
/// the virtual path of the specified area action.
/// </summary>
/// <param name="helper">The HTML helper instance that this method extends.</param>
/// <param name="linkText">The inner text of the anchor element.</param>
/// <param name="actionName">The name of the action.</param>
/// <param name="controllerName">The name of the controller.</param>
/// <param name="areaName">The name of the area.</param>
/// <param name="htmlAttributes">An object that contains the HTML
/// attributes to set for the element.</param>
/// <returns></returns>
public static MvcHtmlString ActionLink(
this HtmlHelper helper,
string linkText,
string actionName,
string controllerName,
string areaName,
object htmlAttributes)
{
return helper.ActionLink(
linkText,
actionName,
controllerName,
new { area = areaName },
htmlAttributes);
}
Tuesday, June 26, 2012
Why doesn't ASP.NET MVC include these HtmlHelper methods?
These HtmlHelper extension methods provide typical use methods for creating action links that include areas. It feels kludgy to have to put "area" into the router values object/dictionary. It seems to me that this (or at least something similar along with additional appropriate overloads) should exist in the core implementation.
Thursday, March 01, 2012
Get the last ELMAH error
I've quickly become quite fond of using ELMAH for handling errors in ASP.NET web apps. There is no better (i.e. custom or otherwise) way that I've found.
I updated an application that was using a messy custom error logging mechanism to use ELMAH and it's already saved me time in tracking down problems while updating the app. The app has a custom errors page that shows a few error details to help the user communicate their problem. It was displaying the old mechanism's error ID so we could cross reference it in the error log database. I needed to replace this with the ELMAH version of the same thing. It turns out to be simple, after I figured out which class to use:
I updated an application that was using a messy custom error logging mechanism to use ELMAH and it's already saved me time in tracking down problems while updating the app. The app has a custom errors page that shows a few error details to help the user communicate their problem. It was displaying the old mechanism's error ID so we could cross reference it in the error log database. I needed to replace this with the ELMAH version of the same thing. It turns out to be simple, after I figured out which class to use:
System.Collections.IList errorList =
new System.Collections.ArrayList();
Elmah.ErrorLog.GetDefault(this.Context)
.GetErrors(0, 1, errorList);
if(errorList.Count > 0)
{
Elmah.ErrorLogEntry entry =
errorList[0] as Elmah.ErrorLogEntry;
// do what you like with 'entry'
}
Thursday, February 23, 2012
ASP.NET MVC Error Handling Flowchart
In an effort to better understand ASP.NET MVC's error handling flow, I did some tests with various configurations of web.config settings and controller/action HandleError attribute decorations (as well as some reading on that type). I think I understand it and thought I'd put together this flowchart to visualize the flow. I hope it is of some use to whomever finds it.
| ASP.NET MVC Error Handling Flowchart |
Monday, November 21, 2011
I donated and so should you.
Monday, November 07, 2011
My professional philosophy: "The General Problem" from xkcd
I don't think anything could describe my professional philosophy more succinctly or clearly than this xkcd comic:
"The General Problem"
"I find that when someone's taking time to do something right in the present, they're a perfectionist with no ability to prioritize, whereas when someone took time to do something right in the past, they're a master artisan of great foresight."
Wednesday, July 13, 2011
It's not easy being green
I had once been directly involved with the development team for an automotive market software product. As a result, I worked with resources from the Automotive Aftermarket Industry Association and ended up on their mailing list for their publication: "Aftermarket Insider" which I receive monthly. Volume 70 arrived recently. I noticed, as often happens with periodical advertising supplements, that the issue was wrapped in a plastic sleeve containing a loose insert along with the primary publication. I thought nothing of it until I noticed the content of the insert. It was very nice, recycled card stock with a printed gloat about how "The automotive aftermarket industry was green long before being green was mainstream."
Really? You tell me this by including it on unnecessarily thick paper enshrouded in plastic?
Instead, you could have emailed that to me in one of your regular blast mails from which I still can't seem to unsubscribe...
*sigh*
Really? You tell me this by including it on unnecessarily thick paper enshrouded in plastic?
Instead, you could have emailed that to me in one of your regular blast mails from which I still can't seem to unsubscribe...
*sigh*
Monday, June 13, 2011
1 Year = 2.6 Million Keystrokes
A look back at my last year of typing.
Having mild OCD is advantageous to being a programmer. But it has its drawback, such as forgetting to take breaks, use the bathroom, eat and sleep. In April 2010, after seeing a coworker using it, I installed Workrave on my work desktop to help my effort to be better about taking breaks. Workrave is a task tray tool that pops up reminders to take micro-breaks (to stretch your various appendages and eyes), longer breaks and can alert you to help limit your overall daily computer use, in whichever combinations you so choose. All of this is an effort to help reduce repetitive stress injuries common among heavy computer users. Along with these features, Workrave tracks your key-presses and mouse movement distance. Since my "mouse" is a trackball and thus never really moves, the mouse movement figures are generally useless. (However, it does track movement time which could be helpful for tracking how long your hand is working the mouse.) The keystroke count is much more concrete, which gave me an idea.
I started recording the daily keystroke stats and now have some impressive numbers. Since April 9th 2010, 2,899,821 keystrokes have been recorded. Excluding those after April 9th of this year, the total is 2,599,992. That's 2.6 Million keystrokes for one calendar year.
I moved the stats from post 4/9/2011 to the beginning to create one complete calendar year, and came up with the following detailed figures:
Some additional information that influences the numbers (positively and negatively):
I took a look back over my daily numbers and journal entries for those high count days. I found that the days I'm writing code, I average around 20,000 keystrokes. So I can make a fairly safe prediction that if I spent most days writing code I would probably have numbers closer to these:
That figure seems pretty crazy to me. I never would have estimated in the millions if I'd been asked how many keystrokes I think I make in a year. Considering that I've been a developer for a solid 11 years, and until recently, most of that has been spent programming, I would venture a guess that I have over 55 million keystrokes under my fingertips. I have trouble fathoming that. My typing teacher in high school would be proud.
Having mild OCD is advantageous to being a programmer. But it has its drawback, such as forgetting to take breaks, use the bathroom, eat and sleep. In April 2010, after seeing a coworker using it, I installed Workrave on my work desktop to help my effort to be better about taking breaks. Workrave is a task tray tool that pops up reminders to take micro-breaks (to stretch your various appendages and eyes), longer breaks and can alert you to help limit your overall daily computer use, in whichever combinations you so choose. All of this is an effort to help reduce repetitive stress injuries common among heavy computer users. Along with these features, Workrave tracks your key-presses and mouse movement distance. Since my "mouse" is a trackball and thus never really moves, the mouse movement figures are generally useless. (However, it does track movement time which could be helpful for tracking how long your hand is working the mouse.) The keystroke count is much more concrete, which gave me an idea.
I started recording the daily keystroke stats and now have some impressive numbers. Since April 9th 2010, 2,899,821 keystrokes have been recorded. Excluding those after April 9th of this year, the total is 2,599,992. That's 2.6 Million keystrokes for one calendar year.
I moved the stats from post 4/9/2011 to the beginning to create one complete calendar year, and came up with the following detailed figures:
- Grand Total: 2,599,992
- Monthly Average: 216,666
- Highest Month: 291,506 (Feb)
- Daily Average: 11,255
- Highest Day: 29,110
Some additional information that influences the numbers (positively and negatively):
- Sometimes I work from home. Occasionally I use remote desktop and work on my desktop where the count is recorded. Some days I don't. This could account for a lower count.
- My work setup includes a laptop. The laptop screens are set up next to the desktop screens and I use Synergy to control both machines from a single keyboard/mouse, giving me a single, contiguous desktop (another tool I highly recommend). The desktop serves as the Synergy server, acting as the input master which allows all input control going to the laptop to pass through the Workrave counters running on the desktop. Occasionally, due to a glitch or a reboot, I won't have primary control so I'll physically switch to the laptop keyboard/mouse. This could account for a reduction in keystroke count, though probably not much.
- I haven't really been doing much programming lately, certainly not as much as in years past. I do a lot of systems administration, infrastructure and other tasks that require less typing. On days that I am actually writing code, my numbers jump significantly. A safe estimate is an average in the 10,000 to 20,000 range, usually towards the high end.
I took a look back over my daily numbers and journal entries for those high count days. I found that the days I'm writing code, I average around 20,000 keystrokes. So I can make a fairly safe prediction that if I spent most days writing code I would probably have numbers closer to these:
- Daily Average: 20,000
- Monthly Average: 418,333
- Yearly Total: 5,020,000
That figure seems pretty crazy to me. I never would have estimated in the millions if I'd been asked how many keystrokes I think I make in a year. Considering that I've been a developer for a solid 11 years, and until recently, most of that has been spent programming, I would venture a guess that I have over 55 million keystrokes under my fingertips. I have trouble fathoming that. My typing teacher in high school would be proud.
Subscribe to:
Posts (Atom)



