September 2006 - Posts

Many people ask me how they can change or add a new connectionstring in Web.Config's connectionstring section. Basically you only need import the System.Web.Configuration namespace, open the Web.Config file where is connectionstrings section and change or add a new connectionstring. An example is:

Configuration webConfig = WebConfigurationManager.OpenWebConfiguration("~");
ConnectionStringsSection dbConnString = webConfig.ConnectionStrings;

//Changing
dbConnString.ConnectionStrings["DBOrders"].ConnectionString = "YOUR NEW CONNSTRING HERE";

//Adding
dbConnString.ConnectionStrings.Add(
    new ConnectionStringSettings("MDBTest", "MDB ConnString", "System.Data.OleDb"));

webConfig.Save();

Posted by israel aece | 2 comment(s)
Filed under:

Those that already worked with Client-Side Callbacks know that when add the reference in control client events; we can to define an error client function that will be gone off if the server-side method throws an exception.

So, there is a problem in this scene: if the server-side method throws an exception and the mode attribute of customErrors section will be with On or RemoteOnly (this is default), your callback never work correctly and the following message will pass as argument for the error client function:

There was an error in the callback.

This error occurs when an exception is throwing, the page is changed and customErrors intercept the process, so the above message is returned for client instead Exception message.

If you define the customErrors as Off, the process will work, but depending of your error handling strategy, this configuration will be able to disclose important details about the error, because it displays for all clients. To resolve this, maybe it’s necessary isolate the page that use the callback in a different directory, add a new Web.Config file, override the customErrors section to Off and involve page’s code in Try.Catch.Finally statement.

Posted by israel aece | with no comments
Filed under:
More Posts