Multiple copy of IIS Site, Databases and Windows services - c#

I have a Big Application build in asp.net 4.5.1 Web form. The Application has two Windows Services. This is a product that we host for different vendors. The client Requirement is to have Separate URL, Database and separate Services. we are getting vendors rapidly, now this became a big problem for me, to update, each url separately, to trace any db changes across the database and implement that separately, and to create separate windows service applications for each vendor and to install that separately on the server. Although I have put code in class libraries so that is shared among all the web and the Windows Service application. but there are other settings, like encryption key, the connection strings to each database, the email settings etc.
can someone please guide me how can I manage multiple copy of same application when there are Windows Service applications too.
Thanks in Advance

I am doing similar things by using different build configurations for that.
Create a new build (solution) configuration for each customer. Right click solution and select 'Configuration Manager'.
Add new configuration with customer name and select to copy settings preferably from Release config.
Once you've done that you are able to switch between those configs next to the debug button in VS.
Go to your web project, right click your Web.config file and select 'Add config Transform'
New config files are created (Web.[ConfigName].config) and placed as sub node under the Web.config file.
These new files are used to transform the original Web.config depending on the selected solution configuration. There's some information in the transform file on how to use it, it is not difficult.
If you would go for automated build process later on, the solution config is the key for that as well. Also if you define publish templates (e.g. to create web deploy packages), you are able to select the config. The transformed web.config is then automatically put into the package.

Related

How to customize class library config settings across projects & clients

Apologies if this has been asked before; after two days of searching I can only find partial answers that don't fully relate to my situation, and are difficult to follow with my lack of experience.
I have a solution that contains four projects:
Class library (containing database connection strings, email server settings, plus lots of other settings)
Web application (web forms)
Web application (MVC)
Web API
Projects 2,3 & 4 all reference the class library, and use the database connection strings, etc, to function. These projects also contain their own additional settings in web.config, bespoke to that project.
Everything works great so far... However, I now need to publish client-specific versions of my solution, e.g. the solution for ClientABC requires different settings for each project than for ClientXYZ. All other aspects remain the same, it is simply the config settings across the four projects that need to change.
From my research, I hit upon something called SlowCheetah which transforms the config files based on the publish profile. That sounded promising, but then I get this problem, where the class library settings aren't pushed into the other projects. I can see bits of useful info in this question, but don't have the experience to apply it to my problem. I'd rather not duplicate the settings into respective project's config file if possible, as that feels messy.
Can anyone please offer me some help as to what's best here? I don't even know if I'm taking the right approach, but am pretty sure I can't be the first ask this?
but then I get this problem, where the class library settings aren't pushed into the other projects
you have to keep in mind that the configuration file is readed by the SturtUp application, your client. Class Library can't run directly, but inside a WebApp or WinApp or ConsoleApp
So, any settings that you put in your ClassLibrary configuration file must be copied in the configuration file of your WebApp.
Generally, I copy some settings from app.config to web.config but, if you search on internet, you can find a method to automate this operation.
I now need to publish client-specific versions of my solution
You can create many configuration profile and use a web.config transformation:
From ToolBar or Build Menu, select Configurazion Manager...
Create all configuration you need for clients
Now you can see different web.configuration files
Now you can specify different configurazion transformation for your ClientABC, ClientXYZ and publish them with specific configuration
EDIT:
So, you can adopt this solution for your Class Library too, or external config file, and include external file in your web.config: External Config

Host Multiple Wcf Services On Local IIS 6

I have tried to google a lot to find a solution to how to host multiple WCF web services on local IIS 6.
So i am asking here. If I can get a step of procedure then i would be glad.
To accomplish your goal this is how to do it:
Create your new solution or just reuse current solution you have.
Create new Project under Visual C# and select WCF Service Application. For sample purposes we name it MultipleHostService project.
It will produce three files named IService1.cs, Service1.svc and Web.config
Under your MultipleHostService project add another New item, under Visual C# Select WCF Service and leave name as is.
It will product addition two files named Iservice2.cs and Service2.svc
Open your Web.Config add Behaviors and Binding configuration highlighted with red box.
If you notice we added Services node and service under it? That is the part that allows us to specify multiple services.
Now click MultipleHostService project
Click Properties
Click Web Tab
In the Servers panel
Select Local IIS in the dropdown list
And under Project URL type this : http://localhost/MultipleHostService "You can change it later on if you want"
And click Create Virtual Directory.
Build the Project MultipleHostService ( Make it sure no failed shown in Error List )
Go to browser and type the follow:
http://localhost/MultipleHostService/Service1.svc
http://localhost/MultipleHostService/Service2.svc
You should see something in the browser like this:
Tools and settings I've used:
Visual Studio 2013
IIS 7
.Net Framework 4.5
Improvements :
You can refactor proper naming for your services.
Remove unnecessary XML node in the configuration file like unused behavior.
Disclaimer : I haven't tested it using IIS 6 but I'm confident that it works on IIS7. Configuration about IIS is not part of this topic so you migt run
some issues which I'm not aware of. There are also some other ways to accomplish multiple hosting of services but this topic is focusing on usage of configuration file. And please do some study on proper Bindings, Behavior and MetaDataExhange which I didn't discuss here.

How I prevent to get latest or check-in a specific file automatically in Team Foundation Server?

I work on a team that works on a project. I change my project web config file to set a specific connection string but when I check-in or get latest version of project it changes to others connection strings. I have same problem in WCF Service references. appconfig and xsd files of service references always corrupted when I check-in or get latest version of program from tfs and I have to delete service references and add it again! How can I get rid of this?
We had the same issue on our project (with connection strings), and found a good solution: http://msdn.microsoft.com/en-us/library/ms254494(v=vs.110).aspx
By adding a connections.config file for each developer with his own connection string, we just needed to say that this file must not be a part of Source Control. Then in the web.config connectionString section, you just refer to the connections.config file.
Just be aware that you need to either transform your web.config or add the connections.config when publishing the site.
I know you can do the same about the appSettings section in the web.config.
How you do it with WCF, I don't know - but it sounds strange to me that your are not using the same WCF refence.
There are many solutions.
The team uses the same configuration (e.g. everyone uses localhost references)
You separate user from application settings (do not apply to all kind of settings nor projects)
Use transforms and solution configuration to map have per-environment setting
Use configSource to move config section in separate files that are not under version control
I do not think there is a perfect solution, but maybe you apply a mix of these. I strongly suggest to apply them in the stated order.

Assign web.config settings based on URL

I have an asp.net/c# website that runs on a dev server and a prod server. We keep the code identical between both servers. Is it possible, based on the URL to assign different settings in the web.config (e.g. for error pages etc)
Ideally I want an IF statement in the web.config e.g.
if (url.contains "http://dev") {
web.config += #'<customErrors mode="Off" />'
} else {
web.config += #'<customErrors mode="On" defaultRedirect="~/web/error.aspx" />'
}
Application configuration files have no direct templating nor scripting support so the approach outlined in the question is not possible. Building configuration files per environment is better placed as part of a build process.
If you are using Visual Studio 2012+ (or 2010 with the Visual Studio Web Publish Update) then you can use web.config transformations to manage the difference configurations across your environments.
This can be made to work for Web Site projects as per the question using some creative thinking. E.g. http://andrewtwest.com/2010/02/25/using-web-config-transformations-in-web-site-projects/. Although this involves creating a separate project for configuration management, it is a considerably less complex approach to implementing a full build process outside of the IDE.
Using this approach, you have a master web.config which contains your base config that is common across environments. In addition, you have a web.config transform file per build configuration that applies transformations specific to that environment. In your case, this would be to turn off customErrors in dev.
More information available here: http://msdn.microsoft.com/en-us/library/vstudio/dd465318(v=vs.100).aspx
But the basic idea is make sure you have all the build configurations you need, then right click on your web.config and select add transforms. These are then applied when the site is deployed using the respective build configuration.

App config windows form application

I just published my windows form application(via Build -> Publish Application) and I told the setup to save it in a map. Now the map contains this:
Application Files(folder) -> sync_1_0_0_4(folder) -> sync.application
Setup.exe sync.exe.config.deploy
sync.application sync.exe.deploy
sync.exe.manifest
And some DLLs. Now I want to change a key from the app config, so the most logical thing to do is to open the sync.exe.config.deploy. As I do I see my app config lines just perfectly normal, so I make the desired changes and I run my application. The problem is, nothing has changed in my application. Am I forgetting something? This is my first time publishing a C# application. I've tried this answer: C# - app config doesn't change but it didn't work.
ClickOnce publication does a lot of things. For one, it does cryptographic verification that files haven't changed, so you can't just edit those files. It also copies all deployment files to somewhere on the user's hard drive, and if the app is not reinstalled, and the version doesn't change, then nothing will be copied. And third, if your settings are user scoped, they may have been changed by the user already and won't be reread from the new app config.
Long story short, if you have to change the config, then you have to redeploy, and make sure your settings are application scoped, not user scoped.

Categories

Resources