0

I have had to add a monoSettings section to my Web.config file as I need to support colons in the url (similar to this question: ASP.NET special characters in URL (colon) not working even with requestPathInvalidCharacters="").

Now when I run my web-api service in visual studio (which I do for ad-hoc testing) it gives an error: "The configuration section 'monoSettings' cannot be read because it is missing a section declaration"

I'm just wondering what is the best way to support this config in my Mono service without impacting being able to run in on Windows? Can I just flag it as optional or unimportant so that it won't fail when trying to read the config? Or is it just better to have a different build configuration for Mono - but I'd then have to maintain two versions of web.config with just this one minor difference.

Community
  • 1
  • 1
procke
  • 75
  • 1
  • 7
  • You could maybe tell .NET that monoSettings is a custom section in the web.config, have a look at http://stackoverflow.com/questions/2155/how-do-i-define-custom-web-config-sections-with-potential-child-elements-and-attr – Vitani May 25 '16 at 10:34

1 Answers1

0

I resolved this issue by adding a configSection to my Web.config as follows:

<configuration>
  <configSections> 
    <sectionGroup name="system.web">
      <section name="monoSettings" type="DataSetSectionHandler,SectionHandlers" />
    </sectionGroup>
  </configSections>
  <system.web>
    <monoSettings verificationCompatibility="1" />
    <httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,%,&amp;,\,?" />
  </system.web>
</configuration>
procke
  • 75
  • 1
  • 7