Modifying web.config with powershell to have smtp section - powershell

I'm trying to modify the web.config with powershell to add a smtp section. I saw this post :
http://ybbest.wordpress.com/2012/02/28/how-to-add-configuration-settings-using-spwebconfigmodification-and-powershell-script/#comment-1070
which add some appsettings defining smtp section. But I want to know if these line:
<add key="businessSupportEmailAddress" value="contosointergenfax#gmail.com" />
<add key="copyMoveTempFolder" value="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\LOGS\SharePointProducts" />
<add key="faxEmailAddress" value="contosointergenfax#gmail.com" />
<add key="fromEmailAccount" value="contosoAdmin" />
<add key="fromEmailAddress" value="contosointergenfax#gmail.com" />
<add key="smtpServerName" value="build.contoso.local" />
<add key="smtpServerPort" value="25" />
are the same as this :
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="testuser#domail.com">
<network defaultCredentials="true" host="localhost" port="25" userName="kaushal" password="testPassword"/>
</smtp>
</mailSettings>
</system.net>
Thanks

Nope.
First block represents key,value pairs that will be loaded in the default hash by the Configuration Manager (appSettings, see http://odetocode.com/Articles/345.aspx).
The other one is the .NET system config for mailing, mostly used in ASP webapps : http://msdn.microsoft.com/en-US/library/w355a94k.aspx

Thanks for visiting my blog and my solution is specific to a SharePoint project we are working on.In the end we actually end up putting the configuration settings into a list as we need the SharePoint timer job to access the configuration settings too.
If your solution is asp.net application , you should use the latter.

Related

aspnet_regiis saying success but connectionString section unchanged

So I have a web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<connectionStrings>
<clear />
<add name="AS400" providerName="System.Data.ProviderName" connectionString="DataSource=REDACTED; UserID=REDACTED; Password=REDACTED; InitialCatalog=REDACTED; DataCompression=True; CheckConnectionOnOpen=True; CharBitDataAsString=True; Naming = System" />
</connectionStrings>
...
And I'm trying to figure out how to encrypt the connectionStrings section, following this documentation.
I navigated to the location of the published web app and ran the following command as an admin: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pe "connectionStrings" -app / -prov "RsaProtectedConfigurationProvider"
The command output the following:
Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Encrypting configuration section...
Succeeded!
...But it didn't seem to do anything! The web.config is unchanged.
I'm probably missing something obvious here but I've never used aspnet_regiis before so I have no idea how to proceed.
I got it. Running it with an app of \ in the correct location isn't good enough. (Likewise, for some reason, navigating to just C:\Windows\Microsoft.NET\Framework64\v4.0.30319 then running aspnet_regiis doesn't work). Need to fully-qualify both paths:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis -pef "connectionStrings" "C:\Atlassian\bamboo-home\xml-data\build-dir\4587526-3997713"

fontawsome-webfont.woff not found error in deployed Orchard CMS website

I use Orchard CMS 1.10.1. In the layout.cshtml file of current theme, I added these:
Style.Require("bootstrap");
Style.Require("fontawesome");
and the web.config file of Orchard.Web contains these:
<staticContent>
<remove fileExtension=".svg" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
</staticContent>
In my machine there was no problem but when I deployed this on server I get these errors in browser console:
Get http://x.com/Themes/y/fonts/fontawesome-webfont.woff2?v=4.3.0
GET http://x.com/Themes/y/fonts/fontawesome-webfont.woff?v=4.3.0
GET http://x.com/Themes/y/fonts/fontawesome-webfont.ttf?v=4.3.0 404 (Not Found)
What might cause this problem?
You need a <clear/> as first element inside static handlers before first <remove..../> and add a ttf handler as well

Installing multiple Quartz.NET services on one machine

I'm using Quartz.NET 2.2.400.0 and am experiencing problems installing multiple instances on a single machine.
I am trying to amend the name of the instance via the configuration file (Quartz.Server.exe) as follows:
<quartz >
<add key="quartz.checkConfiguration" value="false"/>
<add key="quartz.server.serviceName" value="CalSched"/>
<add key="quartz.server.serviceDisplayName" value="CalSched"/>
<add key="quartz.server.serviceDescription" value="CalSchedservice"/>
</quartz>
When running Quartz.Server.exe install without the above, everything works perfectly. When the service name is specified, the scheduler does not run.
I wondered if anybody would be able to shed any light on this?
This is an old thread. But I will put the answer here in case someone got same issue. When <quartz> tag (Quartz.Server.exe.config) is used, quartz will ignore configurations in quartz.config and therefore, this configuration line is ignored quartz.plugin.xml.fileNames = ~/quartz_jobs.xml. As a result, quartz won't read your job settings and won't run the job as expected.
So you need to move all your configuration to tag. You need to add
<quartz >
<add key="quartz.checkConfiguration" value="false"/>
<add key="quartz.server.serviceName" value="CalSched"/>
<add key="quartz.server.serviceDisplayName" value="CalSched"/>
<add key="quartz.server.serviceDescription" value="CalSchedservice"/>
<!-- MUST ADD -->
<add key="quartz.plugin.xml.type" value="Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin, Quartz" />
<add key="quartz.plugin.xml.fileNames" value="~/quartz_jobs.xml" />
</quartz>
And it will work.

IIS 7.5: Special characters in URL rewrite external file

I have ran into the "max web.config size" for one of my applications running on IIS 7.5, Before editing the registry to increase this value, I tried to move all the rewriteMap rules into an external file but the server gave me back a 500 error.
After several checks I've noticed that this way will work
<rewriteMaps>
<rewriteMap name="OLDSITE">
<add key="/withonlythis_will_work" value="http://oldsite" />
</rewriteMap>
</rewriteMaps>
But if I put some non standard alphanumeric character it will crash (e.g.)
oldòsite
<rewriteMaps>
<rewriteMap name="OLDSITE">
<add key="/withonlythis_will_not_work" value="http://oldòsite" />
</rewriteMap>
</rewriteMaps>
Both rules work if I leave them on the webconfig, but the second one does not work on external rewritemap.config file
any clues?
Try to use the HTML named entity for ò that is &ograve ; (please remove space before ';'):
<rewriteMaps>
<rewriteMap name="OLDSITE">
<add key="/withonlythis_will_not_work" value="http://old&ograve ;site" />
</rewriteMap>
</rewriteMaps>

Separate ConnectionStrings and mailSettings from web.config? Possible?

Is it possible to separate ConnectionStrings and mailSettings from web.config?
Devel environment has different IP addresses for connectionstrings and smtp mails because of development and testing. We dont want to do tests and devel using live machines and live IP addresses.
Is it possible?
I found the answer on MSDN:
<configuration>
<connectionStrings configSource="connections.config"/>
</configuration>
With file connections.config containing
<connectionStrings>
<add name="name" connectionString="conn_string" providerName="System.Data.SqlClient" />
<add name="name2" connectionString="conn_string2" providerName="System.Data.SqlClient" />
</connectionStrings>