ConfigurationProperty not returning DefaultValue incase it doesnt exist

669 views Asked by At
[ConfigurationProperty("spatialSRID", DefaultValue = 4326)]
public int SpatialSRID
{
    get { return (int)this["SpatialSRID"]; }
    set { this["SpatialSRID"] = value; }
}

My understand of the above code is that if I do not define the section "SpatialSRID" in my web.config file it will resort to returning 4326 as it has been set as default. However it returns null hence my code blows up.

Now i know i can check for nulls, but I thought that was the purpose of DefaultValue.

1

There are 1 answers

0
Zoinky On BEST ANSWER

Issue: case sensitivity

[ConfigurationProperty("spatialSRID", DefaultValue = 4326)]
public int SpatialSRID
{
    get { return (int)this["spatialSRID"]; }
    set { this["spatialSRID"] = value; }
}