prevent web.config inheritance for SMTP settings RRS feed

  • Question

  • Hello,

    Not sure which forum to post this in so hopefully someone can help.

    I have a child .net 4 web application which is trying to inherit the parent .net 2 web.config file. That's caused some issues, but I've seemed to have resolved most with <clear>. However, in the parent web.config I have some encrypted sections, one of those being the system.net/mailsettings/smtp section. The child application is trying to inherit this but is getting the error "Configuration Section encryption is not supported". I can't seem to use <clear> or any other method to prevent inheritance from occurring in this situation.

    The .Net 2 parent application is in the process of being replaced (as is the web server), but that is still a number of months away. Moving to a subdomain isn't an option as using SSL certificates on multiple sub domains doesn't seem to work in IIS7.5

    Any ideas on how I can resolve this issue?

    • Moved by Alex-KSGZ Thursday, April 25, 2019 6:17 AM
    Tuesday, April 9, 2019 10:21 PM

All replies

  • What we have done was to setup permissions to the application folder so that nothing incoming could see the web.config files so no need for encryption.

    We read them via

    Public Class MailConfiguration
        Private ReadOnly _smtpSection As SmtpSection
        Public Sub New(Optional ByVal section As String = "system.net/mailSettings/smtp")
                _smtpSection = (TryCast(ConfigurationManager.GetSection(section), SmtpSection))
            Catch ex As Exception
                ' It's possible to land here if the following exception is raised
                '    mscorlib.pdb not loaded” yet the mscorlib.dll is NOT missing
                ' The fix
                '    Goto Tools, Options, Debugging, General, Enable Just My Code
            End Try
        End Sub

    Generally speaking say you use ASP command to encrypt a section there should be no special code needed to decrypt in the same app.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Tuesday, April 9, 2019 10:49 PM
  • Not sure which forum to post this in so hopefully someone can help.


    Tuesday, April 9, 2019 10:58 PM