3

I have created a very simple ASP.NET application with a web.config file, which contains a connection string. The connection string is used to connect to a database and return one value (this works).

I am now trying to encrypt the connection string. I use the following command (taken from here: http://msdn.microsoft.com/en-us/library/ff647398.aspx):

C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pe "connectionStrings" -app "/Test".

The command prompt returns "succeeded", but when I look at the web.config (in the Test folder), nothing has changed.

I have Visual Web Developer Express installed on my development PC. This is for testing purposes. Once I am confident with this tool (aspnet_regiis) I will be making a change to a live web app using Visual Studio Professional.

Is there something wrong with the command I am running? Are you not able to encrypt connection strings using Visual Web Developer Express?

1 Answer 1

5

Instead of using -pe, I suggest using -pef and specifying the path to the directory holding the web.config file - this avoid any ambiguity as to what IIS is pointing at.

ASPNET_REGIIS -pef "connectionStrings" "path to directory with web.config"
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks. That has worked. Could you explain what you mean by: "this avoid any ambiguity ". Also do you know how to decrypt the web.config?
@w0051977 - To decrypt you use the -pdf flag. My point about "ambiguity" is that when you specify a web application name, you may think IIS is pointing to one directory but it may be pointing to a different one. When specifying a directory, there is no way to be confused about where the file exists.
Again, thanks that has worked. Do you know what path will be used if I juat select: test, instead of the full path?
@w0051977 - No. It will depend on the current working directory.
@w0051977 - In what environment? If you specify the full path, this is not an issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.