views:

44

answers:

1

I'm working with a CMS which allows you to develop your own custom controls which get dynamically included at runtime. So I have a custom control which alters a datasource (NHibernate cache) and as I'm at a point in the process where the CMS has already read this data from the cache, I need to restart the processing of the page somehow so that the CMS picks up the new cache data.

I know there are probably more elegant ways of doing this, but because I am unable to directly alter the data held by the CMS' core once it has read from the cache and because of the way the control gets loaded by the CMS I am out of alternatives (I think).

I have tried doing a Response.Redirect() to the requested URL, but most browsers will think this is an infinite loop and kill the request. Any other ideas?

+1  A: 

You can do this from your initial page:

Response.Clear ();
Server.Transfer (Request.Url.PathAndQuery, true);

The second argument passes the initial page QueryString and Form values.

Gonzalo
Works perfectly thanks for that! It didn't work immediately and I'll leave a note here for others who may wish to follow me. Request.Url.AbsolutePath didn't work in my particular instance because the CMS uses friendly URLs and so the requested file doesn't physically exist on the server. To get around this I used Request.Url.PathAndQuery which requests the file that the friendly URL maps to. Thanks again Gonzalo
Iain Fraser
Right. I've updated the answer.
Gonzalo
Sweet as bruv :)
Iain Fraser