Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

match element name in web.config transformation

I am trying to match element by element name, I have to change sessionState element timeout in release, but I cannot match it by any attribute value.

<sessionState timeout="5000"/>

How can I match this element in Web.Release.config?

like image 776
Andrija Avatar asked Nov 29 '12 12:11

Andrija


People also ask

What is Xdt transform in web config?

A transform file is an XML file that specifies how the Web. config file should be changed when it is deployed. Transformation actions are specified by using XML attributes that are defined in the XML-Document-Transform namespace, which is mapped to the xdt prefix.

How do I rename a web config transform?

If you are using the extension Configuration Transform go to Build > Configuration Manager and find the Configuration dropdown for the project of which you want to change the app config. You can then select the edit and rename the build configurations for that project.

What is web config transform?

A Web. config transformation file contains XML markup that specifies how to change the Web. config file when it is deployed. You can specify different changes for specific build configurations and for specific publish profiles.

How do I create a new transformation in web config?

If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).


2 Answers

this should work:

<sessionState timeout="2000" 
 xdt:Transform="SetAttributes(timeout)">
</sessionState>
like image 135
tranceporter Avatar answered Nov 11 '22 19:11

tranceporter


In case there are those that would like to change all attributes here it is

<sessionState xdt:Transform="SetAttributes" xdt:Locator="XPath(/configuration/system.web/sessionState)" 
                mode="SQLServer"
                stateConnectionString="tcpip=1234.00" 
                sqlConnectionString="myConnection"
                cookieless="false" 
                timeout="2000"  />
like image 44
Terry H Avatar answered Nov 11 '22 19:11

Terry H