This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- How to edit web.config based on user input
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 03, 2012
03:40 PM
How to edit web.config based on user input
Hi,
How do I edit a web.config based on user input?
I have a dialog that gets some information from the user.
Once the web.config is put down on the disk I want to change some values based on what the user selected at install time.
I tried using StrReplace but it doesn't seem to work.
I'm basically trying to do a simple find and replace in the web.config.
Any help will be much appreciated.
Thanks
How do I edit a web.config based on user input?
I have a dialog that gets some information from the user.
Once the web.config is put down on the disk I want to change some values based on what the user selected at install time.
I tried using StrReplace but it doesn't seem to work.
I'm basically trying to do a simple find and replace in the web.config.
Any help will be much appreciated.
Thanks
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 04, 2012
04:48 AM
You can do that using installscript. try open the file using installscript OpenFile API
Below sample code demo the opening the file and modifying the string.
EXAMPLE_FILE = "web.config";
EXAMPLE_DIR = INSTALLDIR;
if (OpenFile (nvFileHandle, EXAMPLE_DIR, EXAMPLE_FILE) < 0) then
abort;
endif;
while GetLine (nvFileHandle, svLine) = 0
svContent = svContent + svLine + "\r\n";
endwhile;
if (CloseFile (nvFileHandle) < 0) then
MessageBox ("CloseFile failed.", SEVERE);
endif;
StrReplace (svContent, "{{SQLSERVERSETTING}}", szServer, 0);
Give some proper string template for the user input value in web.config and use StrReplace API.
--
Vinay
Below sample code demo the opening the file and modifying the string.
EXAMPLE_FILE = "web.config";
EXAMPLE_DIR = INSTALLDIR;
if (OpenFile (nvFileHandle, EXAMPLE_DIR, EXAMPLE_FILE) < 0) then
abort;
endif;
while GetLine (nvFileHandle, svLine) = 0
svContent = svContent + svLine + "\r\n";
endwhile;
if (CloseFile (nvFileHandle) < 0) then
MessageBox ("CloseFile failed.", SEVERE);
endif;
StrReplace (svContent, "{{SQLSERVERSETTING}}", szServer, 0);
Give some proper string template for the user input value in web.config and use StrReplace API.
--
Vinay
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 04, 2012
06:16 AM
Our project is a Basic MSI and we do somewhat the same thing in that we edit our web.config at install runtime. We first install a seed web.config file containing placeholders such as !ComputerName! for example. Then we use the text edit function to replace the tags/placeholders with the Property value.
I guess the XML edit function could be used, but that requires certain versions of MSXML on the target system and we don't want to deal with another prerequisite at this time. Our update mechanism currently looks for an .msi so we can't simply bootstrap the requirement in a Setup.exe.
Eventually we may move to use a Setup.exe but that, of course is a different discussion.
I guess the XML edit function could be used, but that requires certain versions of MSXML on the target system and we don't want to deal with another prerequisite at this time. Our update mechanism currently looks for an .msi so we can't simply bootstrap the requirement in a Setup.exe.
Eventually we may move to use a Setup.exe but that, of course is a different discussion.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Feb 06, 2012
09:57 AM
Thanks for the response.
I'm not sure what you mean by template in this line.
StrReplace (svContent, "{{SQLSERVERSETTING}}", szServer, 0);
What is the significance of the curly braces?
Thanks
I'm not sure what you mean by template in this line.
StrReplace (svContent, "{{SQLSERVERSETTING}}", szServer, 0);
What is the significance of the curly braces?
Thanks
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 28, 2012
05:40 AM
It is just a template where you can pass the sql server name which you selected in the screen.
![](/skins/images/8CE4FAD0DE6F3A6F9D0567434D2D2DAE/responsive_peak/images/icon_anonymous_message.png)