Adding application config file to web.config - iis-7

I am running IIS7.
I have a 3rd party dll that has its own config file. My understanding is that IIS7 will not read this config file and that I have to add it to the server web.config file.
However I get errors when adding a particular node.
In the dll.config it has:
<configuration>
<dllSettings>
--- bunch of settings....
</dllSettings>
</configuration>
So I added that same node into my web.config file...
Is there a parent node that I should add this to in my web.config?

When I have to add more config file. This is how I defined in the Web.Config
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="[NAMESPACE].[PROJECT].Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<[NAMESPACE].[PROJECT].Properties.Settings configSource="[NAMESPACE].[PROJECT].dll.settings.config"/>
</applicationSettings>
...
</configuration>
This is what I have in my other Config File
<?xml version="1.0" encoding="utf-8" ?>
<[PROJECT].Properties.Settings>
<setting name="[NAME]" serializeAs="String">
<value>Anything</value>
</setting>
</[PROJECT].Properties.Settings>

Related

How to use encrypted web.config in ASP.NET MVC project to get connection string?

I encrypted my web.config file but when I upload the web.config into server the website is not accessible any more.
First I create a key by typing this code in cmd:
aspnet_regiis -pc "MyKeys" -exp
Then I modify web.config like this:
<configuration>
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,
EntityFramework, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false"/>
</configSections>
<configProtectedData>
<providers>
<add name="MyProvider"
type="System.Configuration.RsaProtectedConfigurationProvider,
System.Configuration, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
keyContainerName="MyKeys"
useMachineContainer="true" />
</providers>
</configProtectedData>
<connectionStrings>
<add name="sth" connectionString="Data Source=sth; Initial
Catalog=2888_AtiRayan; User ID=sth; Password=sth; Integrated
Security=False;"
providerName="System.Data.SQLClient"/>
</connectionStrings>
</configuration>
Last I run below code in cmd and web.cofig encrypted successfully.
aspnet_regiis -pef "connectionStrings" "/MyApplication" -prov "MyProvider"
How do I use or decrypt this file?
All I found is decrypting by coding in cmd like above, but I uploaded my source to server and I can't access it so what can I do?
How can I use connection string from this encrypted file which is uploaded to server?

Login does not work in IIS

<?xml version="1.0" encoding="UTF-8"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
<section name="mCSSv2.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="MCSS.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<system.net>
<defaultProxy enabled="true" useDefaultCredentials="true" />
</system.net>
<appSettings />
<connectionStrings>
<add name="ADConnection" connectionString="LDAP://dibpak.com" />
<add name="dib_constr" connectionString="Data Source=172.16.24.150;Initial Catalog=dib_MCSS;User Id=mps;Password=mpsdib;" providerName="Sql.Data.SqlClient" />
<add name="oracle_constr" connectionString="Password=utils;User ID=utils;Data Source=dibhis216;" providerName="OraOLEDB.Oracle" />
<add name="Excel03ConString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}; Extended Properties='Excel 8.0;HDR={1}'" />
<add name="Excel07ConString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Extended Properties='Excel 8.0;HDR={1}'" />
<!--<add name="dib_constrsSql" connectionString="Data Source=172.16.204.37\sql2008;Initial Catalog=EMI;User Id=itih;Password=dib*1234;" providerName="System.Data.SqlClient"/>-->
<add name="dib_constrsSql" connectionString="Data Source=172.16.24.183;Initial Catalog=DIB;User Id=view_user;Password=dibuser#12345;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</assemblies>
</compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
-->
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
<customErrors mode="Off" />
<httpRuntime maxRequestLength="1048576" />
</system.web>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="SYS_Login.aspx" />
</files>
</defaultDocument>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4199999999" />
</requestFiltering>
</security>
</system.webServer>
<applicationSettings>
<mCSSv2.Properties.Settings>
<setting name="mCSSv2_SendEmails_WebService1" serializeAs="String">
<value>http://172.16.3.54/EmailBridge.asmx</value>
</setting>
<setting name="mCSSv2_FCC_FCCCUST" serializeAs="String">
<value>http://172.16.19.34:1781/FCCCUST.asmx</value>
</setting>
<setting name="mCSSv2_RPSAPI_TransactionAPI" serializeAs="String">
<value>http://172.16.25.189/RPSTransactionImportAPI/TransactionAPI.asmx</value>
</setting>
<setting name="mCSSv2_ca_uremit_api_ReceiveAPI" serializeAs="String">
<value>http://api.uremit.ca/ReceiveAPI.svc</value>
</setting>
<setting name="mCSSv2_WebReference_CallNadra" serializeAs="String">
<value>http://172.16.3.208:8090/CallNadra.asmx</value>
</setting>
<setting name="mCSSv2_com_xpresscheque_new_XMSSendTxnService" serializeAs="String">
<value>http://new.xpresscheque.com/XMWS/services/XMSSendTxnService</value>
</setting>
<setting name="mCSSv2_FCC1_FCCCUST" serializeAs="String">
<value>http://172.16.3.54:8013/fcccust.asmx</value>
</setting>
<setting name="mCSSv2_RPSWS_TransactionAPI" serializeAs="String">
<value>http://172.16.24.41/RPSTransactionImportAPI/TransactionAPI.asmx</value>
</setting>
</mCSSv2.Properties.Settings>
</applicationSettings>
</configuration>
I have an asp.net web application which works well on local host using visual studio and plsql database, and Active directory validation for login purpose.
Now the problem is that when i published it on IIS. The login page loads. If i enter the incorrect password it gives me an error saying 'Incorrect password' but if i enter correct password it reloads the page and doesnot proceed any further. Any idea why is this happening?
I tried enabling form authentication, binding and many more settings but to no use :I

Duplicate section error even after using <remove> tag in web.config for IIS

I have a site running in a subdirectory of another site. They run in separate app pools. The two sites are running different versions of Entity Framework. So in the web.config in the subdirectory I have:
<remove name="entityFramework"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
But even with the <remove> tag I still get this error:
Section or group name 'entityFramework' is already defined. Updates to this may only occur at the configuration level where it is defined.
I've also placed <location> tags in the parent web.config wherever possible:
<location path="." inheritInChildApplications="false">
The <location> tag is present around the parent web.config's <entityFramework> section.
And I've placed enableConfigurationOverride="false" in the applicationHost.config files for IIS (both files in System32 and SysWOW64).
How do I prevent the site in the subdirectory from seeing the parent entityFramework tag?
EDIT
IIS Version: 7.5.7600.16385
From the parent web.config:
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
l
<location path="." inheritInChildApplications="false">
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</location>
From the child web.config:
<configSections>
<remove name="entityFramework"/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
l
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
EDIT 2
In regards to using <clear/>: this causes a series of errors about missing section declarations. If I add back ~100 lines of section declarations I get the error: An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. The error persists even if I use <validation validateIntegratedModeConfiguration="false" /> in <system.webServer>.
Can you confirm if you tried clear instead of remove the problem still persist or not?
<configSections>
<clear/>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
You might read more here
Hope this will help you
You said that you used but in the parent web.config you posted, the path="." is missing. You're going to need that for it to block the inheritance.
Have you tried this Removeattributes
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
http://weblogs.asp.net/srkirkland/common-web-config-transformations-with-visual-studio-2010
Example 2

aspnet_regiis section not found

i'm trying to encrypt my web.config.
aspnet_regiis keeps telling me: The configuration section 'applicationSettings' was not found.
I followed this site: Walkthrough: Creating and Exporting an RSA Key Container
My web.config looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="x" type="x" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="x.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<configProtectedData>
<providers>
<add name="MyProvider"
type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0. 0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a,
processorArchitecture=MSIL"
keyContainerName="MyKeys"
useMachineContainer="true" />
</providers>
</configProtectedData>
...
<applicationSettings>
<x.Properties.Settings>
<setting name="PollingInterval" serializeAs="String">
<value>10000</value>
</setting>
</x.Properties.Settings>
</applicationSettings>
</configuration>
I use the command: aspnet_regiis -pe "applicationSettings" -app "/MyApplication" -prov "MyProvider"
When I move the Section configProtectedData above the configSections it encrypts the applicationSettings, but removes the configSections-Section, anyway, IIS tells me configSections need to be the first element. I'm not sure what I'm doing wrong.
Is it a problem, that the applicationSettings is listed in the configSections?
Thank you for your help.
Ok, found the solution,
as stated in "configSections", "applicationSettings" is a SectionGroup, not a Section. aspnet_regiis can only encrypt Sections.
so I had to go one deeper: aspnet_regiis -pe "applicationSettings/x.Properties.Settings" -app "/MyApplication" -prov "MyProvider"

Hosting xamlx Workflow service in IIS 7.5 errors out

I created the most basic webservice using the Receive/SendReply with WWF 4 (.Net 4). I am not posting the code since the problem is related with deployment.
The documentation and therefore my expectation is that the xamlx file and web.config file along with the dll files have to be copied to the IIS application and bin folders, which I have done. The service works fine when launched via Visual Studio however when I copy the files to the IIS folder, it gives the following error.
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
I have checked against the web.config provided in the WWF samples and find that they are the same, however I am posting the file here.
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings />
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Just expanding on Maurice's comment:
You should run aspnet_regiis.exe -i as an administrator.
I had this file in: C:\Windows\Microsoft.NET\Framework\v4.0.30319
After executing it (it took around 5 seconds) I had all the mappings needed for the workflow to run.
It sounds like you are missing the httpHandler for the workflows. Normally this is in your machine web.config.
<configuration>
<configSections>
<sectionGroup name="system.xaml.hosting"
type="System.Xaml.Hosting.Configuration.XamlHostingSectionGroup, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="httpHandlers"
type="System.Xaml.Hosting.Configuration.XamlHostingSection, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</sectionGroup>
</configSections>
<system.xaml.hosting>
<httpHandlers>
<add xamlRootElementType="System.ServiceModel.Activities.WorkflowService, System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
httpHandlerType="System.ServiceModel.Activities.Activation.ServiceModelActivitiesActivationHandlerAsync, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add xamlRootElementType="System.Activities.Activity, System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
httpHandlerType="System.ServiceModel.Activities.Activation.ServiceModelActivitiesActivationHandlerAsync, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpHandlers>
</system.xaml.hosting>

Resources