views:

28

answers:

1

We began a project using WebForms, and developed a somewhat complex portal system to accommodate breadcrumbs, navigation, and so forth. We keep an extra navigation context ID parameter on the URL at all times, so that we can track the user's breadcrumb history robustly even if they are using multiple tabs or using the navigation buttons on their browser. In order for this to work properly in WebForms, all non-postback links need to be generated by the portal's utility methods. We get a number of benefits from using the portal's utility methods, so it's really not a burden. And since any actions that take place on a given page will use postbacks, the URL doesn't change when these actions are performed.

Now we're beginning to use MVC for some parts of our site, and the transition has so far been relatively smooth. I'd like to make sure our portal can be used properly without really getting in the way, though. So far, we are using some custom HtmlHelper extension methods to generate links between various pages (even though "pages" don't really exist in MVC, certain actions have the effect of rendering the entire page). This allows us to keep the navigation context ID on the URL for page actions. In order to avoid losing this URL parameter, however, we are only using AJAX requests for any actions within the page. This prevents us from being able to respond to most action requests with a full View, or follow a Post-Redirect-Get pattern.

While I'm a big fan of AJAX, and we technically don't plan to support browsers without javascript enabled, etc., I would nevertheless like to leave our options open. So I'd like to be able to make it so that any time a link or form gets rendered via the built-in HtmlHelper methods, I can have a hook into the URL construction, and append the context ID to the URL query parameters. Is there any (preferably easy) way to do this? Or do you see another solution to my problem that would be better?

+1  A: 

There is no way to get into the existing HTMLHelper's code paths. Your going to have to roll your own. There is hope, you could probably get away with superficial facades that just pass through to the existing html helper.

jfar