Tag Archive : web.config

Handling multiple configuration settings (Development, Staging, Production) gracefully.

1
Digg me

In Asp.net 2.0 multiple connectionStrings & appSettings can be handled very easily using the attribute “configSource”

create a new xml file devAppSettings.config under a new folder myConfigsettings

<?xml version=”1.0″?>
<appSettings>

  <add key=”uploadfolder” value=”C:\test\UploadDocs”/>

  <add key=”domainname” value=”devdomain”/>

</appSettings>

create a new xml file devconnectionStrings.config under a folder myConfigsettings

<?xml version=”1.0″?>
<connectionStrings>

  <add name=”nwind” connectionString=”Data Source=(localhost);Initial Catalog=nwind;User Id=sa;Password=sa;”
    providerName=”System.Data.SqlClient” />

</connectionStrings>

now modify web.config

<connectionStrings configSource=”myConfigsettings\devconnectionStrings.config”/>

<appSettings configSource=”myConfigsettings\devAppSettings.config” />
Similarly you can create as many config files for testing, production and change the name in Web.config

tstAppSettings.config

prdAppSettings.config

Tip: Unlike web.config,  these config files wont kill the session of current users if you accidentally enter a space and save the file.

How can I upload larger files with ASP.NET?

0
Digg me

By default, the file size limit on uploads in ASP.NET is 4mb.  If you need to upload more than 4 MB .. here you go

To upload larger files through HTTP, you can use a configuration setting in your application Web.config file or your machine Web.config file:

Replace [ ] with angle brackets

[configuration]

[system.web]

[httpRuntime maxRequestLength="10000" /]

[/system.web]

[/configuration]
where “10000″ is the file size in Kbytes that you want to allow.  You can go upto 1GB.

If webservice is called for saving the files, then this configuration has to be made in both the applications.

WebService application and Web application.