6

I would like to remove the entire element sessionState from my web.config using transformation.

I have tried , but the element wasn't removed.

    <?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.serviceModel>
    <client>
      <!-- Some endpoints -->
    </client>
  </system.serviceModel>
  <sessionState xdt:Transform="Remove" />
  <system.net>
    <!--Email para ambiente de teste-->
    <mailSettings>

      <!-- SMTP CONFIG -->

    </mailSettings>
  </system.net>
</configuration>

2 Answers2

2

Your transformation is correct.

I think the issue here is that you're expecting the transformation to take place when you Build the website in different modes(Debug\Release etc) but you need to understand that the transformation will only run when you Publish the web application.

You can test this by simply publishing to a folder on your local machine.

Denys Wessels
  • 16,829
  • 14
  • 80
  • 120
1

I forgot to use the <system.web> tag on my transformation. I realize it a while a go. Thanks for the responses.

`

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    <system.serviceModel>
       <client>
         <!-- Some endpoints -->
       </client>
    </system.serviceModel>
    <system.web>
      <sessionState mode="InProc" xdt:Transform="SetAttributes" />
    </system.web>
    <system.net>
    <mailSettings>
        <-- SMTP CONFIG -->
    </mailSettings>
  </system.net>
</configuration>`