Mari Jørgensen
Apr 4, 2008
  9260
(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 Forms: You cannot submit this form because an administrator has turned off data storage.

Do not let this error message scare you, the solution is quite simple!

Tomas Hensrud Gulla | Oct 4, 2024 | Syndicated blog

Add your own tools to the Optimizely CMS 12 admin menu

The menus in Optimizely CMS can be extended using a MenuProvider, and using the path parameter you decide what menu you want to add additional menu...

Tomas Hensrud Gulla | Oct 3, 2024 | Syndicated blog

Integrating Optimizely DAM with Your Website

This article is the second in a series about integrating Optimizely DAM with websites. It discusses how to install the necessary package and code t...

Andrew Markham | Sep 28, 2024 | Syndicated blog

Opticon 2024 - highlights

I went to Opticon in Stockholm and here are my brief highlights based on the demos, presentations and roadmaps  Optimizely CMS SaaS will start to...

Daniel Ovaska | Sep 27, 2024