11

I need to make a quick Sitecore admin script to inspect a series of items. I need to do this without compiling my solution. I made a sample ASPX page under /sitecore/admin/ using:

<script runat="server" language="text/c#">

but when I try to view it I get Sitecore telling me ItemNotFound.

Is this type of 'pure script' page supported under Sitecore? Is there a piece of functionality I am missing?

  • Adding this as a comment as it's not an answer to your specific question, but if you haven't already I would strongly recommend you investigate the Sitecore Powershell Extensions module. Once installed on your Sitecore instance, this will allow you to run scripts to inspect / interact with items without requiring compilation. It's perfect for those sort of admin tasks but does lots more too! – Kasaku Oct 13 '16 at 16:18
6

I wasnt extending the adminpage base class. My script tag should have read like this:

<%@ Page Language="c#" Inherits="Sitecore.sitecore.admin.AdminPage" %>

There a good writeup and example page in this post on BrainJocks.

4

If Sitecore is telling you ItemNotFound, then it's trying to resolve your request to a content item. Being your admin page is a physical file, the issue is most likely that you've not included the file extension in the request.

For example, to access the ShowConfig admin page I must include the aspx extension of the file when I request it:

http://mysite/sitecore/admin/showconfig.aspx

If I leave the aspx off, I'll get an ItemNotFound error.

2

Here you go, sample code snippet for that:

<%@ Page Language="c#" EnableEventValidation="false" AutoEventWireup="true" %>

<script runat="server">
    void Page_Load(object sender, System.EventArgs e)
    {
        repValues.DataBind();
    }

    public IEnumerable<string> Names
    {
        get
        {
            return new[] { "1", "2" };
        }
    }
</script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
    <title>Example Admin page</title>
</head>
<body>
    <form runat="server">
        <div>
            <asp:Repeater ID="repValues" runat="server" DataSource="<%# Names %>">
                <ItemTemplate>
                    <%# (Container.DataItem as string) %>
                    <br />
                </ItemTemplate>
            </asp:Repeater>
        </div>
    </form>
</body>
</html>

EDIT: I am glad that you solved your issue ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.