Wednesday, 11 December 2019

Web.config file sample in asp.net / How to write connection string in web.config



<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <section name="resizer" type="ImageResizer.ResizerSection" requirePermission="false" />
  </configSections>
 
    <connectionStrings>
     <add name="DAEntities" connectionString="metadata=res://*/App_Code.Model.csdl|res://*/App_Code.Model.ssdl|res://*/App_Code.Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=san-PC;initial catalog=Database_Name;integrated security=False;user id=sa;password=devdba; MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    
     <add connectionString="data source=san-PC;initial catalog=Database_Name;integrated security=False;user id=sa;password=devdba;" name="connectionstring" />
    </connectionStrings>
   
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
    <add key="smtp_email" value="online@____.com" />
    <add key="smtp_password" value="_______" />
    <add key="smtp_host" value="smtp.gmail.com" />
    <add key="smtp_port" value="587" />
    <add key="smtp_ssl" value="true" />
    <add key="website_title" value=" :: website name" />
    <add key="is_mail_enable" value="true" />
    <add key="version" value="1.10" />
  </appSettings>
 
  <system.web>
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
      <buildProviders>
        <add extension=".edmx" type="System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider" />
      </buildProviders>
    </compilation>
   
    <machineKey validationKey="078A068393098252DAB62414111EE993A63851F105DFD47984F6FC91290CC04A21346601E310127FB78B7279BB51A587EE85439B397F7B2C04002977A08D48DC" decryptionKey="B395E1984BD2DDE3D08F5FF3DFA60E9B4F04DB50A560AD4C98EC2DC6E773067C" validation="SHA1" decryption="AES" />
    <httpRuntime enableVersionHeader="false" relaxedUrlToFileSystemMapping="true" requestPathInvalidCharacters="" requestValidationMode="4.0" targetFramework="4.5" maxRequestLength="2097151" executionTimeout="36000" />
    <authentication mode="Windows" />
   
    <customErrors mode="Off"></customErrors>
   
    <sessionState customProvider="DefaultSessionProvider" mode="InProc">
      <providers>
        <add connectionStringName="DefaultConnection" name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </providers>
    </sessionState>
   
     <httpCookies httpOnlyCookies="true" requireSSL="false" />
   
     <httpModules>
      <add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
      </httpModules>
     
      <pages validateRequest="false" enableViewStateMac="false" viewStateEncryptionMode="Never" enableEventValidation="false" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
       <controls>
        <add tagPrefix="CKEditor" assembly="CKEditor.NET" namespace="CKEditor.NET" />
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
       </controls>
      </pages>
     
  </system.web>
  <system.webServer>
    <httpCompression directory="%SystemDrive%\websites\_compressed" minFileSizeForComp="1024">
      <scheme dll="%Windir%\system32\inetsrv\gzip.dll" name="gzip" />
      <staticTypes>
        <add enabled="true" mimeType="text/*" />
        <add enabled="true" mimeType="message/*" />
        <add enabled="true" mimeType="application/javascript" />
        <add enabled="true" mimeType="application/json" />
        <add enabled="false" mimeType="*/*" />
      </staticTypes>
    </httpCompression>
    <httpErrors errorMode="Custom" existingResponse="PassThrough">
      <remove statusCode="404" subStatusCode="-1" />
      <error path="/notfound" responseMode="ExecuteURL" statusCode="404" subStatusCode="-1" />
      <remove statusCode="500" subStatusCode="-1" />
      <error path="/error" responseMode="ExecuteURL" statusCode="500" subStatusCode="-1" />
    </httpErrors>
   
    <directoryBrowse enabled="false" />
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="false">
      <add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
    </modules>
    <urlCompression doDynamicCompression="true" doStaticCompression="true" />
    <staticContent>
      <clientCache cacheControlMaxAge="30.00:00:00" cacheControlMode="UseMaxAge" />
      <remove fileExtension=".html" />
      <mimeMap fileExtension=".html" mimeType="text/html; charset=UTF-8" />
      <remove fileExtension=".css" />
      <mimeMap fileExtension=".css" mimeType="text/css" />
      <remove fileExtension=".js" />
     
    </staticContent>
    <httpProtocol>
      <customHeaders>
        <remove name="X-Content-Type-Options" />
        <add name="X-Content-Type-Options" value="nosniff" />
        <remove name="X-Powered-By" />
        <add name="X-Powered-By" value="My Little Pony" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect newVersion="2.0.0.0" oldVersion="1.0.0.0-2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect newVersion="2.0.0.0" oldVersion="1.0.0.0-2.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
</configuration>

No comments:

Post a Comment