I create a new web setup project within this i add Contents using Add Output project option. Now i install it, its working fine but, i have two probelms
1. During login page the system meet Connection String problem. In my project i wrote connection string within Web.Config file. After installation the system meet this connectionstring problem.
How to solve the sql connection string problem
2. I see the installed Virtual directory folder all of my pages is there and can open & view all source code. But, i want to protect my source code, i have DotFuscCator but it obfuscate only the dll or exe files. How to project my code during installation.
Any doubts please feel free to ask me. If this post is answer of your question then don't forgot to Click "Mark As Answer".
J.Jeyaseelan
1) it's possible to have a second (or more) web.configs and swap (& rename) the correct one into a setup package. (But only have one properly named web.config at a time!) eg: in your solution you could have web.configDEV, web.configTEST etc. You can put
the correct connection strings in for each deployment and configure the installer to install and rename the correct file. This can be done by excluding the web.config from the normal output and adding the alternative web.config as a single 'add file' in the
setup project, then change it's 'target' filename.
2) have you thought of 'publishing' the site:
http://msdn2.microsoft.com/en-us/library/aa983453(VS.80).aspx this way the source code can be pre-compiled - hiding the source code (although as you say without obsfucation people can still reverse-engineer the compiled assemblies if they really wanted
to and know how.. In practice unless there is really sensitive information hidden in your source code there's little to worry about from people stealing your code! If you have real 'business secrets' in your source code that you're concerned about then you
should consider buying professional obsfucation tools.
1. During login page the system meet Connection String problem. In my project i wrote connection string within Web.Config file. After installation the system meet this connectionstring problem.
If you want to change the Database connection string using Web Setup project while installing, you can try to add the
custom action to your Web Setup project to configure the Database connection string.
2. I see the installed Virtual directory folder all of my pages is there and can open & view all source code. But, i want to protect my source code, i have DotFuscCator but it obfuscate only the dll or exe files. How to project my code during installation.
In your case, I guess your project is Asp.net website project instead of Asp.net web application project. If so, you can add the
Visual Studio 2005 Web Deployment Projects to pre-compilation your website to protect the source code. If you do so, you can configure the Web Setup project to use the output from
your Website Deployment project.
I hope this helps.
Thomas Sun
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
Thanks for your nice reply. I understand your answer. May i know what is Web site project and what is web application project. Is any advantages over web application
compared to web site project ?
Any guide for how to use web deployment projects ?
Any doubts please feel free to ask me. If this post is answer of your question then don't forgot to Click "Mark As Answer".
J.Jeyaseelan
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
but i am getting error an compilation time, which is given below.
1. The type or namespace could not be found.
2. The name space WebConfigurationManager does not exists.
while i am already added
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.DirectoryServices;
using System.Diagnostics;
using System.Configuration;
name spaces.
is DATABASE_CONNECTION_KEY represents the key name of connection string of web config file?
One another thing, i want to know, do i need to add additional dialog to supply
jeyaseelan@a...
Contributor
5124 Points
2025 Posts
Web setup project : sql connectionstring problem
Apr 21, 2008 05:19 AM|LINK
hullo to all,
I create a new web setup project within this i add Contents using Add Output project option. Now i install it, its working fine but, i have two probelms
1. During login page the system meet Connection String problem. In my project i wrote connection string within Web.Config file. After installation the system meet this connectionstring problem.
How to solve the sql connection string problem
2. I see the installed Virtual directory folder all of my pages is there and can open & view all source code. But, i want to protect my source code, i have DotFuscCator but it obfuscate only the dll or exe files. How to project my code during installation.J.Jeyaseelan
DiscernIT
Participant
1488 Points
244 Posts
Re: Web setup project : sql connectionstring problem
Apr 21, 2008 12:22 PM|LINK
1) it's possible to have a second (or more) web.configs and swap (& rename) the correct one into a setup package. (But only have one properly named web.config at a time!) eg: in your solution you could have web.configDEV, web.configTEST etc. You can put the correct connection strings in for each deployment and configure the installer to install and rename the correct file. This can be done by excluding the web.config from the normal output and adding the alternative web.config as a single 'add file' in the setup project, then change it's 'target' filename.
2) have you thought of 'publishing' the site: http://msdn2.microsoft.com/en-us/library/aa983453(VS.80).aspx this way the source code can be pre-compiled - hiding the source code (although as you say without obsfucation people can still reverse-engineer the compiled assemblies if they really wanted to and know how.. In practice unless there is really sensitive information hidden in your source code there's little to worry about from people stealing your code! If you have real 'business secrets' in your source code that you're concerned about then you should consider buying professional obsfucation tools.
hth
http://pIIq.co.uk
see it; do it
jeyaseelan@a...
Contributor
5124 Points
2025 Posts
Re: Web setup project : sql connectionstring problem
Apr 22, 2008 11:09 AM|LINK
Hai DiscernIT,
Thanks for your interest. But i want to know how to set the connection string during installation by coding.
J.Jeyaseelan
DiscernIT
Participant
1488 Points
244 Posts
Re: Web setup project : sql connectionstring problem
Apr 22, 2008 11:24 AM|LINK
the best way of writing code for run during install is by writing an installer: http://msdn2.microsoft.com/en-us/library/system.configuration.install.installer.aspx
not sure how you access the target web.config file at install time though. sounds a little tricky!
http://pIIq.co.uk
see it; do it
Thomas Sun –...
All-Star
64969 Points
5621 Posts
Re: Web setup project : sql connectionstring problem
Apr 24, 2008 06:01 AM|LINK
Hi,
If you want to change the Database connection string using Web Setup project while installing, you can try to add the custom action to your Web Setup project to configure the Database connection string.
For example, see http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx (Section 7: Useful Custom Action Example: Configuring Database Connection String).
In your case, I guess your project is Asp.net website project instead of Asp.net web application project. If so, you can add the Visual Studio 2005 Web Deployment Projects to pre-compilation your website to protect the source code. If you do so, you can configure the Web Setup project to use the output from your Website Deployment project.
I hope this helps.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
jeyaseelan@a...
Contributor
5124 Points
2025 Posts
Re: Web setup project : sql connectionstring problem
Apr 24, 2008 06:35 AM|LINK
Dear Thomas,
Thanks for your nice reply. I understand your answer. May i know what is Web site project and what is web application project. Is any advantages over web application
compared to web site project ?
Any guide for how to use web deployment projects ?
J.Jeyaseelan
Thomas Sun –...
All-Star
64969 Points
5621 Posts
Re: Web setup project : sql connectionstring problem
Apr 24, 2008 09:05 AM|LINK
Hi,
Thanks for your response and I am glad to help you.
In your case (for deployment), you can get some information from http://msdn2.microsoft.com/en-us/magazine/cc163448.aspx.
For differences between them, you can refer to http://forums.asp.net/p/1150861/1876473.aspx.
I hope this helps.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
jeyaseelan@a...
Contributor
5124 Points
2025 Posts
Re: Web setup project : sql connectionstring problem
Apr 24, 2008 09:31 AM|LINK
Ahhh...what a great article, now i understand. Me to not installed service pack1 by that asp.net web application is not display in my machine.
Thanks for your nice reply
J.Jeyaseelan
prabhatasp
Member
95 Points
88 Posts
Re: Web setup project : sql connectionstring problem
Mar 10, 2009 11:34 AM|LINK
Hi Sir Thomas,
I am reading artical on link http://weblogs.asp.net/scottgu/archive/2007/06/15/tip-trick-creating-packaged-asp-net-setup-programs-with-vs-2005.aspx which you mensioned on your above post and crating a custom action to my websetup project to change connectionstring at installation time.
I am using the function
private void ConfigureDatabase(string targetSite, string targetVDir, string connectionString)
{
// Retrieve "Friendly Site Name" from IIS for TargetSite
DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/" + targetSite);
string friendlySiteName = entry.Properties["ServerComment"].Value.ToString();
// Open Application's Web.Config
Configuration config = WebConfigurationManager.OpenWebConfiguration("/" + targetVDir, friendlySiteName);
// Add new connection string setting for web.config
ConnectionStringSettings appDatabase = new ConnectionStringSettings();
appDatabase.Name = DATABASE_CONNECTION_KEY;
appDatabase.ConnectionString = connectionString;
config.ConnectionStrings.ConnectionStrings.Clear();
config.ConnectionStrings.ConnectionStrings.Add(appDatabase);
// Persist web.config settings
config.Save();
}
but i am getting error an compilation time, which is given below.
1. The type or namespace could not be found.
2. The name space WebConfigurationManager does not exists.
while i am already added
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.DirectoryServices;
using System.Diagnostics;
using System.Configuration;
name spaces.
is DATABASE_CONNECTION_KEY represents the key name of connection string of web config file?
One another thing, i want to know, do i need to add additional dialog to supply
/targetdir="[TARGETDIR]\" /targetvdir="[TARGETVDIR]" /targetsite="[TARGETSITE]"
parameters or it will not required to supply bu using additional dialog.
Please help me.
Web setup project : sql connectionstring problem
prabhatasp
Member
95 Points
88 Posts
Re: Web setup project : sql connectionstring problem
Mar 12, 2009 11:12 AM|LINK
Hello Sir,
I have passed the three parameters in ConfigureDatabase() function..
string targetSite = Context.Parameters["targetsite"];
string targetVDir = Context.Parameters["targetvdir"];
string connectionString = GetLogin(
Context.Parameters["databaseServer"],
Context.Parameters["userName"],
Context.Parameters["userPass"],
"TrainTrack");
ConfigureDatabase(targetSite, targetVDir, connectionString);
public void ConfigureDatabase(string targetSite, string targetVDir, string connectionString)
{
// Retrieve "Friendly Site Name" from IIS for TargetSite
DirectoryEntry entry = new DirectoryEntry("IIS://LocalHost/" + targetSite);
string friendlySiteName = entry.Properties["ServerComment"].Value.ToString();
// Open Application's Web.Config
Configuration config = WebConfigurationManager.OpenWebConfiguration("/" + targetVDir, friendlySiteName);
// Add new connection string setting for web.config
ConnectionStringSettings appDatabase = new ConnectionStringSettings();
appDatabase.Name = "TrainTrack";
appDatabase.ConnectionString = connectionString;
config.ConnectionStrings.ConnectionStrings.Clear();
config.ConnectionStrings.ConnectionStrings.Add(appDatabase);
// Persist web.config settings
config.Save();
}