Efficient Page Reloading in ASP .NET
Today I ran into a situation where I needed to change some session state information on an ASP page I was developing and have it instantly update the current page. This can be accomplished with the following code:
//Stop processing and reload the current pageServer.Transfer(Request.Path);
Server.Transfer()
transfers execution to a specified ASP page that does not force a new page request. This is more efficient than the old Response.Redirect()
way of doing things.
Request.Path
will get the path of the current request. Which, more simply put, will point straight back to the page you are currently on.
Put these two together and you have a recipe for success when you want to make your page stop processing and begin again.
Subscribe for Free
Want to stay ahead of the curve? Subscribe now to receive the latest updates, actionable insights, and thought-provoking ideas around business, technology, and leadership straight to your inbox.