Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7558287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:19:56+00:00 2026-05-30T12:19:56+00:00

I am looking for a quick and dirty way to query the layouts files

  • 0

I am looking for a quick and dirty way to query the layouts files of a particular page by its friendly url. This is probably easy, but I can’t find the solution.

Basically I want to say something like the following. Pseudo-code:

var mainpage = Sitecore.EasyQueryUtility.GetItemByFriendlyUrl(requestedUrl);

or

var mainpage = Sitecore.EasyQueryUtility.GetOppositeOfFriendlyUrl(friendlyurl);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:19:57+00:00Added an answer on May 30, 2026 at 12:19 pm

    It sounds like you want to do two things here:

    1. Determine an item based on its rendered URL in the address bar (i.e. friendly URL)
    2. Determine the layout being used by the item once you determine the item.

    If those are correct, hopefully this can help you out:

    Note: untested code I did on-the-fly

    // if you have the full URL with protocol and host
    public static Item GetItemFromUrl(string url)
    {
        string path = new Uri(url).PathAndQuery;    
        return GetItemFromPath(path);
    }
    
    // if you have just the path after the hostname
    public static Item GetItemFromPath(string path)
    {
        // remove query string
        if(path.Contains("?"))
            path = path.split('?')[0];
    
        path = path.Replace(".aspx", "");
    
        return Sitecore.Context.Database.GetItem(path);
    }
    

    Once you have the item you can get the layout’s name like so:

    item.Visualization.GetLayout(Sitecore.Context.Device).Name;
    

    Or the layout’s physical file path to the ASPX:

    item.Visualization.GetLayout(Sitecore.Context.Device).FilePath;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a quick-and-dirty way to import CSV files into SQL Server
I am looking for a quick but not-so-dirty way to do snapshots of a
I'm looking for a quick and dirty way in Java to flash up a
I'm looking for a quick and easy way to strip non-alphanumeric characters from an
I'm looking for a quick and easy way to preload images with JavaScript. I'm
I'm looking for a quick, easy and reliable way of getting the browser's HTTP
I'm looking for a quick-and-dirty solution to this, I have to set up a
I am looking for a quick and dirty way to allow a user to
I'm looking for a quick way to log some data - I seem to
Note: I've read this and its not quite what I'm looking for: I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.