H
Hey it's Filippo
ASP.NET 2.0
Windows app written in C# and VS 2005
=============================
I am having difficulties encryting web.config files when using Cassini (IIS is currenly disabled) as the VirtualDirectory param seems to only work when IIS is up and running.
The idea is that we want our windows app, that uses a browser component to run local sites, to work on OS that don't have IIS. So we need to embed Cassini in order to make it work.
And all works perfectly ...all but the call to encrypt the web.config.
I am trying 2 different techniques:
1) Configuration object
FileAttributes attr = FileAttributes.Archive | FileAttributes.Normal;
File.SetAttributes(Constant.FolderWebsite + @"\Web.Config", attr);
Configuration config = WebConfigurationManager.OpenWebConfiguration("/MyWebSiteVirtualDir");
ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection;
if (section.SectionInformation.IsProtected == false)
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
2) Run a command using AspNet_RegIIS
string param = "-pe \"connectionStrings\" -app \"/MyWebSiteVirtualDir\" -prov \"DataProtectionConfigurationProvider\"";
Process myProcess = new Process();
object o = new object();
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.FileName = "aspnet_regiis";
myProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(o.GetType().Assembly.Location);
myProcess.StartInfo.Arguments = param;
myProcess.Start();
myProcess.WaitForExit();
myProcess.Close();
Both techniques work when IIS is up and running because it returns the physical path of the MyWebSiteVirtualDir.
QUESTION
How can I make this working when IIS is not present?
Is there a different way to encrypt a web config without having the need of IIS?
Thanks,
Filippo
Windows app written in C# and VS 2005
=============================
I am having difficulties encryting web.config files when using Cassini (IIS is currenly disabled) as the VirtualDirectory param seems to only work when IIS is up and running.
The idea is that we want our windows app, that uses a browser component to run local sites, to work on OS that don't have IIS. So we need to embed Cassini in order to make it work.
And all works perfectly ...all but the call to encrypt the web.config.
I am trying 2 different techniques:
1) Configuration object
FileAttributes attr = FileAttributes.Archive | FileAttributes.Normal;
File.SetAttributes(Constant.FolderWebsite + @"\Web.Config", attr);
Configuration config = WebConfigurationManager.OpenWebConfiguration("/MyWebSiteVirtualDir");
ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection;
if (section.SectionInformation.IsProtected == false)
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
2) Run a command using AspNet_RegIIS
string param = "-pe \"connectionStrings\" -app \"/MyWebSiteVirtualDir\" -prov \"DataProtectionConfigurationProvider\"";
Process myProcess = new Process();
object o = new object();
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.FileName = "aspnet_regiis";
myProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(o.GetType().Assembly.Location);
myProcess.StartInfo.Arguments = param;
myProcess.Start();
myProcess.WaitForExit();
myProcess.Close();
Both techniques work when IIS is up and running because it returns the physical path of the MyWebSiteVirtualDir.
QUESTION
How can I make this working when IIS is not present?
Is there a different way to encrypt a web config without having the need of IIS?
Thanks,
Filippo