GetConnectionString Method

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/12/2012 12:27:33 PM
Gravatar
Total Posts 88

GetConnectionString Method

Hi,

Is there any technical reason for all class's on mojoportal.Data.[Plataform] as the repeated method?

private static string GetConnectionString()
{
     return ConfigurationManager.AppSettings["MSSQLConnectionString"]; 
}

I'm asking this because i need to encrypt only this key on web.config and in this way is several class that i need to fork.

If exits a class "DBHelper" for example for every plataform that has this methods this code doesn't need to repeat but i know the effort to make this change.

Other thing i think was great it's add a class some where with all const string for appsettings. this prevent the extensive web.config and all comments would be present in this class. The best way is create a project to manage all const string from web.config and all shared enums and other.

this is my ideas, and i'm glad to work with mojo and makes mojo the better CMS Platafform...

thanks

 

6/13/2012 4:26:38 PM
Gravatar
Total Posts 18439

Re: GetConnectionString Method

Hi Luis,

Back in the early days of my work with mojoPortal I felt that the connection string should not be a public method or property so I implemented it as private method in each data access class. But my opinion has changed and I agree with you that it would be better to consolidate it in one place so it isn't duplicated in all the different data classes. If you check the latest code in the repository you will see that I have gone through all the classes in the MS SQL data layer and changed them to all use a common method to get the connection string. I will do the same in other data layers as time permits, it is easy to make the changes but its a lot of changes so its a large tedious project to complete it.

This would make it possible to have a config switch to make it possible to use the <connectionStrings section if you don't want to use <appSettings (I haven't made that option yet but I will), then you could encrypt just the <connectionStrings section or you could encrypt <appSettings section and use it as it is today.

I would not encrypt just one key, that would mean you have to decrypt it on every data access and that affects performance. It is better to encrypt a web.config section because that is decrypted just once when the configuration object is cached into memory and we don't have to have any decryption logic anywhere in our code, it is done by the runtime at the point when it reads the section the first time and puts it in memory.

Most appSettings are already encapsulated in the Web/Components/WebConfigSettings.cs class, but that exists in mojoPortal.Web project so it cannot be used in the data layer, since it has no reference to the web layer.

Best,

Joe

6/14/2012 3:25:58 AM
Gravatar
Total Posts 88

Re: GetConnectionString Method

Hi joe,

Thanks a lot for your effort.

Great work...

 

You must sign in to post in the forums. This thread is closed to new posts.