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 8571221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:44:11+00:00 2026-06-11T18:44:11+00:00

I got a problem for a website I was working on. A WebMethod is

  • 0

I got a problem for a website I was working on.
A WebMethod is called from a JavaScript function:

var ajaxOptions = {
    url: "/layouts/foobar/Foo.aspx/GetBar"
}
$.ajax(ajaxOptions).done(function(result) { 
    loadResult(result, a);
});

The method GetBar in Foo.Aspx looks like this:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static object GetBar()
{
    return FoobarManager.GetItems();
}

The function returns a valid JSON object.
Sitecore is used in the FoobarManager. Example:

Context.Database.GetItem("/sitecore/content/foobar");

On the development and test environment things ran very smoothly with no problems what so ever. After the deployment to the staging environment I saw that the response of the GetBar function was our custom 404 page. I figured this was because Sitecore was trying to resolve the path “/layouts/foobar/Foo.aspx/GetBar” and failed.

Since it worked on the D and T environment, it must be a configuration problem.
I added the GetBar url to the IgnoreUrlPrefixes setting.
This resulted in a 500 response in the ajax call: the Sitecore.Context.Database was null.
I figured it had something to do with the ItemResolver but I can’t understand WHY it worked on D and T but not on A.

What can I do to resolve the url correctly?

  • 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-06-11T18:44:12+00:00Added an answer on June 11, 2026 at 6:44 pm

    You have two conflicting things. If you add the /layouts/foobar/Foo.aspx path to the IgnoreUrlPrefixes setting which you MUST do (as you did), then Sitecore will not run its context in that. That means, your code Context.Database... is invalid. I recommend you get the DB by name. Do you need the published “web” DB? You’ll need to figure out which one you need but something like this:

    var db = Sitecore.Configuration.Factory.GetDatabase("web"); // assumes you need the web DB
    var foobar = db.GetItem("/sitecore/content/foobar");
    

    TL;DR: There is no context so you can’t get the DB from it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this from php.net website. This is related to the problem I am
I got my uiwebview working and displaying the specified url. the only problem is
We integrated a wysiwyg editor in our website. Now we got the problem that
I've stumbled upon an interesting problem while playing with my website. So I've got
I've got problem for my application. I want to start connectbot from my application
have a nice day. I got problem when trying to create an image from
I'm working on a website where I need to show/hide table rows. I got
I actually working on a website-project. Behind my website, I´ve got a database with
I'm now working on a challenge from website http://www.net-force.nl/challenges/ and I stand before an
I'm working on this website: http://india.kentlewis.net/book1.html . I've got a series of thumbnails displayed

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.