0

I am trying web.config encryption for server deployment. I am using the aspnet_regiis.exe for encryption of the connection string.

In this project there are multiple datasets for the database calls.

how can I set decryption for all these datasets from one place as I cannot set decryption for each of the datasets nor can I keep the encrypted file during development. after encryption the

<connectionstring></connectionstring>

gets converted to

<encrypteddata></encrypteddata>

so application crashes at the

  ((global::System.Data.SqlClient.SqlCommand)(this._commandCollection[0])).Connection = new global::System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString)

in the typed dataset as it is not able to ApplicationServices as now it is encrypted in the encrypted data

Anurag.Desai
  • 103
  • 1
  • 15
  • You can create a factory which will be responsible for creating the datasets and decryption – Aman B Jan 18 '18 at 11:20
  • For more information on factory design pattern see https://msdn.microsoft.com/en-us/library/ee817667.aspx – Aman B Jan 18 '18 at 11:20
  • 1
    Could you explain more? IIS automatically decrypts config sections as they are accessed. And what does a DataSet have to do with a config file? Do you mean connection strings? – Crowcoder Jan 18 '18 at 12:08
  • @Crowcoder I want to encrypt the connection string. But the decryption is needed for the string in the dataset but its not able to decode the encrypted file and gives an error cannot the encrypted file – Anurag.Desai Jan 18 '18 at 13:02
  • Well, like I said, you don't need to decrypt it, IIS does so automatically. If you have correctly encrypted the section you can just access ConfigurationManager.ConnectionStrings. – Crowcoder Jan 18 '18 at 13:27
  • After encryption the gets converted to which is not deceypted by the connection string set in the typed dataset ((global::System.Data.SqlClient.SqlCommand)(this._commandCollection[0])).Connection = new global::System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString) – Anurag.Desai Jan 24 '18 at 05:51
  • @Crowcoder answer is right the IIS will decrypt the web.config. If running the file on local host it will crash but on attaching to the IIS the IIS decrypts the file – Anurag.Desai Feb 03 '18 at 07:51

0 Answers0