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

  • Home
  • SEARCH
  • 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 3947734
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:17:14+00:00 2026-05-20T01:17:14+00:00

I have ran into a really annoying issue which gives me this error: The

  • 0

I have ran into a really annoying issue which gives me this error: “The given key was not present in the dictionary.”

What I don’t get is that it worked perfectly as intedded last friday and the days before that. I have debugged, checked if the webservice files were intact etc. It all fits.

All I did last friday was running a script which ran trough all of the items in my list which contains the article pages and edited their creation date. I don’t know if that could have changed something, but that’s the only thing I can recall.


ASPX.CS

protected void Page_Load(object sender, EventArgs e)
    {
        var listId = Request.QueryString["ListID"];
        var itemId = Request.QueryString["ItemID"];

        try
        {
            var spList = SPContext.Current.Web.Lists[new Guid(listId)];
            var item = spList.GetItemById(int.Parse(itemId));
            var image = (ImageFieldValue)item["PublishingPageImage"];
            var contentType = (string)item["ContentType"];
            var pageLayout = (string) item["PublishingPageLayout"];

            var news = new News
            {
                Title = (string)item["Title"],
                NewsId = item.UniqueId,
                Content = (string)item["PublishingPageContent"],
                ArticleDate = item["ArticleStartDate"] == null ? DateTime.Now : (DateTime)item["ArticleStartDate"],
                PageName = item.File.Name,
                Author = new SPFieldUserValue(SPContext.Current.Web, (string)item["Author"]).User.LoginName,
                IsArticle = contentType.Contains("Article"),
                PageLayout = GetLayout(pageLayout),
                Image = GetImage(image)
            };

            // Jumps to the WSInstance class.
            WSInstance.InternetInstance().PublishNews(news); // This line throws the exception.
            lblMessage.Text = "News '<i>" + news.Title + "</i>' have been published succesfully to the Internet site.";
        }
        catch (Exception ex)
        {
            EventLogger.LogError("Error occured while publishing news: " + ex.Message + "\n" + ex.StackTrace, this);
        }
    }

WSINSTANCE

public static WSIntegration InternetInstance(SPSite spSite)
    {
        // Jumps to the Configuration class.
        var url = Configuration.GetConfigurationValue("Progressive.WS.Internet", spSite);
        ...
        return new WSIntegration
                   {
                       Credentials = new NetworkCredential(username, password, domain),
                       Url = url
                   };
    }

    public static WSIntegration InternetInstance()
    {
        return InternetInstance(SPContext.Current.Site);
    }

CONFIGURATION

public static class Configuration
{
    public static string GetConfigurationValue(string key, SPSite site)
    {
        var name = site.WebApplication.IisSettings[site.Zone].ServerComment; // This is where it fails and throws the error: "The given key was not present in the dictionary."
        var value = "";
        SPSecurity.RunWithElevatedPrivileges(() => { value = WebConfigurationManager.OpenWebConfiguration("/", name).AppSettings.Settings[key].Value; });
        return value;
    }
}

The section which it gets hold of the data from the web.config file.

<appSettings><add key="Progressive.WS.Internet" value="http://shpt02/_layouts/DR/WSIntegration.asmx" /> // This is the key value it cannot find.
<add key="Progressive.WS.Internet.Username" value="user" />
<add key="Progressive.WS.Internet.Password" value="password" />
<add key="Progressive.WS.Internet.Domain" value="domain" /></appSettings>
  • 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-20T01:17:15+00:00Added an answer on May 20, 2026 at 1:17 am

    The error says that it can’t find the site’s Zone in the IisSettings dictionary. You should check both the value of the Zone property and the contents of the IisSettings dictionary. They may not contain the values you expect, since you access the IisSettings outside RunWithElevatedPrivileges, ie. with the end user’s access rights.

    In any case storing application settings in web.config is not the best option in SharePoint, as a web application hosts many site collections and sites. Modifying it causes all the sites to restart and recompile – not a good end user experience!

    Check the Application Settings Manager section in the Sharepoint 2010 Guidance for an alternative way that stores settings in the appropriate site’s property bag.

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

Sidebar

Related Questions

I have ran into a very strange issue with Google Maps in Chrome 5.0.375.99:
I ran into this today and have no idea why the C# compiler isn't
I currently ran into a problem I can not really solve by myself: I
Ok, I ran into this tree question which LOOKED simple, but started driving me
I've been working on optimizing a query and have ran into a situation that's
I'm working with the PieChart and PieSeries components in Flex, and have ran into
Here's a problem I ran into recently. I have attributes strings of the form
I just ran into an annoying problem. Suddenly Avira AntiVir started to flag one
I have really no idea why I'm asking this as this a really completely
I ran into a little problem today when I was creating a really quick

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.