Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.

 

Mari Jørgensen
Apr 4, 2008
  9376
(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
Image Analyzer with AI Assistant for Optimizely

The Smart Image Analyzer is a new feature in the Epicweb AI Assistant for Optimizely CMS that automates the management of image metadata, such as...

Luc Gosso (MVP) | Jan 16, 2025 | Syndicated blog

How to: create Decimal metafield with custom precision

If you are using catalog system, the way of creating metafields are easy – in fact, you can forget about “metafields”, all you should be using is t...

Quan Mai | Jan 16, 2025 | Syndicated blog

Level Up with Optimizely's Newly Relaunched Certifications!

We're thrilled to announce the relaunch of our Optimizely Certifications—designed to help partners, customers, and developers redefine what it mean...

Satata Satez | Jan 14, 2025

Introducing AI Assistance for DBLocalizationProvider

The LocalizationProvider for Optimizely has long been a powerful tool for enhancing the localization capabilities of Optimizely CMS. Designed to ma...

Luc Gosso (MVP) | Jan 14, 2025 | Syndicated blog

Order tabs with drag and drop - Blazor

I have started to play around a little with Blazor and the best way to learn is to reimplement some old stuff for CMS12. So I took a look at my old...

Per Nergård (MVP) | Jan 14, 2025

Product Recommendations - Common Pitfalls

With the added freedom and flexibility that the release of the self-service widgets feature for Product Recommendations provides you as...

Dylan Walker | Jan 14, 2025