When a user clicks on a link on my page, I want to be able to record that link click then send the user off to that link in another window.
Given the following ActionLink:
@Html.ActionLink(Model.dsResults.Tables[0].Rows[i]["title"].ToString(), "LinkClick", new { itemListID = @Model.dsResults.Tables[0].Rows[i]["ItemListID"] })
The LinkClick ActionResult will be called with the ItemListID past to it. However, I don’t want to go back through my model/db to get the link. Can I pass a DataRow type and get the cell containing the link and other details, and secondly, once I have saved the link click, how do I redirect the user, in a new window, to that link?
Are there Razor HTML helpers for this kind of thing?
Thanks.
UPDATE
Seems that I’ve forgotten some of the basics… while the discussion with Malcolm regarding using caching holds some value, how about the following:
In the past, what I would do is link to an internal page which would open _blank, take in the ID, do the DB call to save, then redirect the user in that window to the appropriate URL.
I think this clarifies the issue a lot.
There is no such helper available. I couldn’t 100% follow how you want this scenario to work, but the idea is that you should use jQuery to attach to the click event, call some tracking url via .ajax, and then return so the original link click is processed.
Then your javascript block somewhere after the link:
When the call returns the original link url will be processed.