Difference between revisions of "Web.config Edits"

From KOP KB
Jump to: navigation, search
(Web.config SSL Redirect)
Line 1: Line 1:
 +
You may need to only copy some parts as the may have a web.config file already created
 +
 
== Web.config SSL Redirect ==
 
== Web.config SSL Redirect ==
You may need to only copy some parts as the may have a web.config file already created
+
 
 +
This is the way to redirect for ssl, first to www then to https
 
<syntaxhighlight lang="xml">
 
<syntaxhighlight lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
Line 10: Line 13:
 
   <match url="*" />             
 
   <match url="*" />             
 
   <conditions>                 
 
   <conditions>                 
   <add input="{HTTP_HOST}" pattern="cherokeestatebank.com" />             
+
   <add input="{HTTP_HOST}" pattern="domain.com" />             
 
   </conditions>             
 
   </conditions>             
   <action type="Redirect" url="http://www.cherokeestatebank.com/{R:0}" />         
+
   <action type="Redirect" url="http://www.domain.com/{R:0}" />         
 
   </rule>
 
   </rule>
 
     <rule name="HTTP to HTTPS redirect" stopProcessing="true">
 
     <rule name="HTTP to HTTPS redirect" stopProcessing="true">
Line 46: Line 49:
 
This is the connection string where your only changing data source, initial catalog, User ID, Password
 
This is the connection string where your only changing data source, initial catalog, User ID, Password
 
-->
 
-->
         <add name="51134_testConnectionString" connectionString="Data Source=209.17.116.5;Initial Catalog=simongtest123;Persist Security Info=True;User ID=simongtest123;Password=Simongtest123"
+
         <add name="51134_testConnectionString" connectionString="Data Source=hostname;Initial Catalog=dbname;Persist Security Info=True;User ID=userid;Password=Simongtest123"
 
             providerName="System.Data.SqlClient" />
 
             providerName="System.Data.SqlClient" />
<add name="51134_testConnectionString2" connectionString="Data Source=209.17.116.5;Initial Catalog=simongtest123;Persist Security Info=True;User ID=simongtest123;Password=Simongtest123"
+
<add name="51134_testConnectionString2" connectionString="Data Source=hostname;Initial Catalog=dbname;Persist Security Info=True;User ID=simongtest123;Password=Simongtest123"
 
             providerName="System.Data.SqlClient" />
 
             providerName="System.Data.SqlClient" />
 
 

Revision as of 17:11, 5 August 2014

You may need to only copy some parts as the may have a web.config file already created

Web.config SSL Redirect

This is the way to redirect for ssl, first to www then to https

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
      <rewrite>
  <rules>
  <rule name="Redirect domain.com to www" patternSyntax="Wildcard" stopProcessing="true">            
  <match url="*" />            
  <conditions>                
  <add input="{HTTP_HOST}" pattern="domain.com" />            
  </conditions>            
  <action type="Redirect" url="http://www.domain.com/{R:0}" />        
  </rule>
    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
  <match url="(.*)" />
    <conditions>
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
</rule>
  </rules>
  
</rewrite>
    </system.webServer>
</configuration>

Connection Strings and Config Source

Well below is good example of how you can do data strings for your asp.net application. Also you will notice one has a configsource so for every tag in a web.config you can provide an alternate source for the rest of that configuration. So your data strings you see there for connection we could of stored all of them in a separate file.

<syntaxhighlight lang="xml"> <?xml version="1.0"?>


<configuration>

   <connectionStrings>
       <add name="51134_testConnectionString" connectionString="Data Source=hostname;Initial Catalog=dbname;Persist Security Info=True;User ID=userid;Password=Simongtest123"
           providerName="System.Data.SqlClient" />

<add name="51134_testConnectionString2" connectionString="Data Source=hostname;Initial Catalog=dbname;Persist Security Info=True;User ID=simongtest123;Password=Simongtest123"

           providerName="System.Data.SqlClient" />
   </connectionStrings>

<connectionStrings configSource="ConnectionStrings.config" />

   <system.web>
       <customErrors mode="Off"/>
   </system.web>


</configuration> <syntaxhighlight>