ASP.Net MVC Tip: URL Anchor Tags

This is one of those features which should be baked into MVC by default, but isn’t.

Actually, it is partially supported by MVC. This Codeplex answer details it:


    "Link Text",           // linkText
    "Action",              // actionName
    "Controller",          // controllerName
    null,                  // protocol
    null,                  // hostName
    "fragment",            // fragment
    new { id = "123" },    // routeValues
    null                   // htmlAttributes

will produce (assuming default routes):

<a href="/Controller/Action/123#fragment">Link Text</a>

But what if you want the returned redirect of an ActionResult method to include the anchor tag. There is no RedirectAnchorTagResult to return.


That same answer does some voodoo to pull it off:

public ActionResult Index()
    var url = UrlHelper.GenerateUrl(
        new RouteValueDictionary(new { id = "123" }),
    return Redirect(url);


It is this that should be baked into MVC by default. Thats an awful lot of complexity to expose just for the sake of a simple anchor tag. So, yes, a RedirectAnchorTagResult would be a nice addition.


Thanks to Darin Dimitrov for providing the answer. Go ahead and upvote his answer.

Codeplex Projects of the Week.

Two Codeplex projects have come in quite handy for  me this week and I thought I’d pass them on.


WSUS 3.0 – WSUS Smart Approve

I installed Windows Server Update Services on my Windows Home Server 2011 this week.

As usual, I was in a bit over my head. I hit the Approve All Updates nuclear option. Knowledgeable sysadmins are possibly cringing or screaming at me (or both). By the time i figured out that approving updates puts them in the download queue, 4 and a half gigabytes were in the queue. Ordinarily this wouldn’t be a problem. But my broadband has had issues and it’s ridiculously slow (0.85 MBPS) and WSUS was eating up all the bandwidth.

So this was a problem. The solution was, of course to approve and download only needed updates. Amazingly, WSUS has no way of automatically approving needed updates (even as a checkbox buried five or six option screens down and off by default).

So, Codeplex to the rescue!

WSUS Smart Approve does exactly what it says on the tin – automatically approving updates according to certain rules. One of those is, of course, to approve needed updates automatically.


MetaWeblogAPI – ooMetaWeblog

One of the nice things about the MetaWeblogAPI is that almost everyone supports it. One of those is, of course, Windows Live Writer 2011.

Using Windows Live Writer as a WYSIWYG editor would be convenient.

There are a number of options to implement a server-side MetaWeblogAPI endpoint. Scott Hanselman has one approach.

I used another approach  – the Matlus.MetaWeblogAPI.

The corresponding Codeplex project is ooMetaWeblog.


Hope they come in helpful for somebody.

Codeplex Project Updates

Meant to do this quick rundown a few weeks back.

  • WCF Client Server Chat– No new development. However, I do think that I’ll have a ready to run version to post. No timing on this. But since this is apparently the most popular project here, I’m feeling the pressure.
  • RSSCloudNotify. Yes, there is a bug in the code. Sometimes it makes it through to the server and sometimes not. This project is in active development, it being a part of my honours year project for uni. The current build was a quick test project to get an idea of the scale of the task. So it WILL be re-written properly leveraging the full ASP.Net stack.
  • WHS2Smugmug. This is also under active development, albeit with a hiatus while I complete my last few months at uni. I have definitely not forgotten about this. Currently, its awaiting testing and revising before releasing a beta. (Don’t forget to follow the project on twitter @whs2smugmug)
  • FFNotify – No new development for awhile. But I do plan to fix the bugs in the current revision. Freindfeed is pretty snappy importing blogs now, so this is not exactly high priority (if you feel different, give me a shout).

Naturally, all the above fixes etc (save for RSSCloudNotify) are subject to how things go at uni. Indeed, some of the stuff I will be writing for my honours year project directly translate back to these projects.

These are all projects that I care deeply about. And are projects that I stated to solve my own problems. Unfortunately there are only so many hours in the day 🙂

Thanks for your interest and support.