November Happy Hour will be moved to Thursday December 5th.

Mari Jørgensen
Apr 4, 2008
  9315
(0 votes)

Accessing CurrentPage from a static context

Ever needed access to the CurrentPage object inside a static method or property?
As long as you have a valid HttpContext this code will do the trick

PageBase pageBase = HttpContext.Current.Handler as PageBase;
string pageName = pageBase.CurrentPage.PageName;
Apr 04, 2008

Comments

Sep 21, 2010 10:32 AM

Nice sample! However, I'm a bit confused - aren't these types of posts supposed to be published on labs.episerver.com? Or what's the purpose of blogs here at EPiServer World as opposed to those on Labs? Cheers!
/ Ted Nyberg

Mari Jørgensen
Mari Jørgensen Sep 21, 2010 10:32 AM

Well, we had the same discussion here in Norway just last week, without arriving to a conclusion. I'll look into it.

Please login to comment.
Latest blogs
Optimizely SaaS CMS + Coveo Search Page

Short on time but need a listing feature with filters, pagination, and sorting? Create a fully functional Coveo-powered search page driven by data...

Damian Smutek | Nov 21, 2024 | Syndicated blog

Optimizely SaaS CMS DAM Picker (Interim)

Simplify your Optimizely SaaS CMS workflow with the Interim DAM Picker Chrome extension. Seamlessly integrate your DAM system, streamlining asset...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Optimizely CMS Roadmap

Explore Optimizely CMS's latest roadmap, packed with developer-focused updates. From SaaS speed to Visual Builder enhancements, developer tooling...

Andy Blyth | Nov 21, 2024 | Syndicated blog

Set Default Culture in Optimizely CMS 12

Take control over culture-specific operations like date and time formatting.

Tomas Hensrud Gulla | Nov 15, 2024 | Syndicated blog

I'm running Optimizely CMS on .NET 9!

It works 🎉

Tomas Hensrud Gulla | Nov 12, 2024 | Syndicated blog

Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog