ConfigurationSettings.AppSettings[key]

Mar 17 2008 6:29 AM

i get an error when i try to access a web service.
The webservice is internally developed by another developer who has left. The website uses 'Sitecore' to render
its pages through a subscription model.
Therefore a cookie is passed to the webservice to access the value of the appsettings to retrieve the data.

I am not able to access the value of the appsettings 'key'. Please look at 'somestring' in the webconfig file.
A string 'xxxxxx' is passed to cookie to verify. Also it looks like only safe addresses will be authenciated in the config file.


Below are:
1. the code im executing.
2. the error page.
3. The app.config file

Please advise as to how i could retrieve the 'key'.

************************************************************************************************************
1. Code consuming the webservice
*********************************************************************************************************

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using Breakingviews.www.BreakingViewsWebService;
using Breakingviews.Configuration;
using System.Web.Services.Protocols;
using System.Net;

public partial class MostRead : System.Web.UI.Page
{
    private ContentInfoService BuildContentInfoService()
    {
        ContentInfoService contentInfoService = new ContentInfoService();
        AddxxxxxxxCookies(contentInfoService);
        return contentInfoService;
    }

    static void AddMagicCookies(SoapHttpClientProtocol webService)
    {
        CookieContainer cookieContainer = new CookieContainer();
        string secret = BvConfiguration.GetConfigurationString("SomeString");
        Uri uri = new Uri(webService.Url);
        cookieContainer.Add(new Cookie("xxxxxxx", secret, "/", uri.Host));

        webService.CookieContainer = cookieContainer;
    }

    public void ListReadyStories()
    {
        ContentInfoService service = BuildContentInfoService();
        Guid[] stories = service.ListReadyStories(60);
        //List<Guid> storyList = new List<Guid>(stories);
        Response.Write(stories.ToString());
    }

    protected void Page_Load(object sender, EventArgs e)
    {


        ListReadyStories();

    }
}

*******************************************************************************************
2. Error page i get when i view MostRead.aspx in Browser
*******************************************************************************************
Server Error in '/' Application.
--------------------------------------------------------------------------------

Couldn't find type for class Breakingviews.WebModules.AssertHealth.AssertListener, Breakingviews.WebModules.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Configuration.ConfigurationErrorsException: Couldn't find type for class Breakingviews.WebModules.AssertHealth.AssertListener, Breakingviews.WebModules.

Source Error:


Line 29:             {
Line 30:                   string settingValue = ConfigurationSettings.AppSettings[key];
Line 31:             Debug.WriteLine("Read configuration value " + key + "=" + settingValue);
Line 32:                   return settingValue;
Line 33:             }
 

Source File: C:\BackUp\code\dotnet\Breakingviews.Configuration\BvConfiguration.cs    Line: 31

Stack Trace:


[ConfigurationErrorsException: Couldn't find type for class Breakingviews.WebModules.AssertHealth.AssertListener, Breakingviews.WebModules.]
   System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData) +1902756
   System.Diagnostics.TypedElement.BaseGetRuntimeObject() +42
   System.Diagnostics.ListenerElement.GetRuntimeObject() +82
   System.Diagnostics.ListenerElementsCollection.GetRuntimeObject() +134
   System.Diagnostics.TraceInternal.get_Listeners() +134
   System.Diagnostics.TraceInternal.WriteLine(String message) +105
   System.Diagnostics.Debug.WriteLine(String message) +4
   Breakingviews.Configuration.BvConfiguration.GetConfigurationString(String key) in C:\BackUp\code\dotnet\Breakingviews.Configuration\BvConfiguration.cs:31
   Breakingviews.Configuration.BvConfiguration.GetConfigurationTimeSpan(String key, TimeSpan defaultValue) in C:\BackUp\code\dotnet\Breakingviews.Configuration\BvConfiguration.cs:47
   Breakingviews.WebModules.ConcurrentUsageModule..cctor() in C:\BackUp\code\dotnet\Breakingviews.WebModules\ConcurrentUsageModule.cs:28

[TypeInitializationException: The type initializer for 'Breakingviews.WebModules.ConcurrentUsageModule' threw an exception.]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +103
   System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +268
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1036
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +114
   System.Web.Configuration.Common.ModulesEntry.Create() +41
   System.Web.Configuration.HttpModulesSection.CreateModules() +203
   System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1006
   System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +259
   System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +114
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +350

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

********************************************************************************************************************
3. Section of the webconfig file
**********************************************************************************************************
Webconfig file under <appsettings>:


<add key="Secretsomeotherkey" value="{643E7B39-991F-487c-AA52-B408071BGFDE9}!~secret~!{5B68008E-5054-4oc7-B7E2-1C82E0BF5965}"/>
      <!-- the password that is passed (as a cookie) to access the webservice
            This isn't particularly secure (it's passed as plaintext) but the webservice itself
            is designed for this to be broken -->
      <add key="SomeString" value="{0BD4523-3A2D-4880-81H4-278GG20FC6A4}"/>
      <!-- The list of IP addresses that the internal web services will listen to, separated by semi-colons (;) -->
<add key="SomeStringforSafeAddresses" value="127.0.0.1;222.33.30.122;222.131.113.222;192.1.1.6;192.1.1.233;192.1.1.254"/>