How to get GUID of current page?

Hello. Is it possible to get GUID of current page? I would like to store it to list to identify data. Something like SPContext.Current.ItemId.
LVL 1
tolppaAsked:
Who is Participating?
 
ivan_vaguninConnect With a Mentor Commented:
Hi!
Try:
SPFile file = SPContext.Current.Web.GetFile(HttpContext.Current.Request.Url.AbsoluteUri);
Guid pageId = file.UniqueId;

Note, that this will not work for application pages (inside /_layouts/). Consider using page url instead of guid, because page url is unique and can be used for pages of all types.
0
 
tolppaAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.