简体   繁体   中英

How do I go about getting a page to restart processing in C#?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM