6
votes

I used aspnet_regiis successfully encrypted web.config file which running on windows 2003 server. However it doesn't work in IIS 7 on Windows 7/2008 server.

When I try to run the followng command in 64bit Windows 2008 server, it always shows the aspnet_regiis options help. The same thing is in windows 7 OS.

C:\Windows\Microsoft.Net\Framework64\v2.0.50727\aspnet_regiis –pe “appSettings” –app “/ConnectionTest” –site 4

If I open Visual Studio 2008 command in windows 7 and run the following command, I got those. I use the site Id from iis manager.

aspnet_regiis –pe “appSettings” –app “/ConnectionTest” –site 4 Failed to resolve the site ID for '4' Failed!

2

2 Answers

18
votes

Have you tried running a command window "As Administrator"? This just caught me out for a moment too but running as admin fixed it.

0
votes

I was getting this error even after running command prompt as an administrator. But I observed that the virtual directory in my case had multiple words separated by dot. Like "Web.Api.XYZApi".

I changed the virtual directory name to "XYZApi" (without the dots) and tried encrypting and it worked. But I'm still not sure why that should be an issue.