I have this in my root web.config
<mailSettings> <smtp from="[email protected]" deliveryMethod="SpecifiedPickupDirectory"> <specifiedPickupDirectory pickupDirectoryLocation="C:\temp"/> <network host="localhost"/> </smtp> </mailSettings>
Of course when I put this to my hosting server I don't want it to be saving to the harddrive I want it to send out the emails.
So I would have something like this
<system.net> <mailSettings> <smtp deliveryMethod="Network"> <network host="smtp.mysite.com" userName="myuser" password="mypassword" /> </smtp> </mailSettings> </system.net>
How could I put this in my web.release.config? Should I just do a replace of the mailSettings. I am not sure really how to the transforms yet.
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).
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.
XDT is a simple and straight forward method of transforming the web. config during publishing/packaging. Transformation actions are specified using XML attributes defined in the XML-Document-Transform namespace, that is mapped to the xdt prefix.
Add xdt:Transform="Replace"
to your .release
<system.net> <mailSettings> <smtp deliveryMethod="Network" xdt:Transform="Replace"> <network host="smtp.mysite.com" userName="myuser" password="mypassword" /> </smtp> </mailSettings> </system.net>
You could use web.config transformation in asp.net 4
you would write a transformation rule to match a local rule to be replaced when you are publishing your website in a specific transformation
there is some great information on this here
http://blog.hmobius.com/post/2010/02/17/ASPNET-40-Part-4-Config-Transformation-Files.aspx (Archived version)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With