Skip to content

Using Visual Studio 2012 Web Publish For Staging On The Internet

Updated: at 05:05 PM

 

Let’s say you have a production code like http://siliconvalley-codecamp.com and you want to have a test site on the internet that will not be seen by anyone unless they login (or maybe even login as an admin).  Using web.config (with Visual Studio 2012), transformations makes that very straight forward.  I know because I just did that.  I created a test site (say: http://test.siliconvalley-codecamp.com) and set up my publish to replace my normal anonymous authentication (allowing anonymous users) to one that denies anonymous users.  Just as an aside, the reason I did this was I notice that google was indexing some of those pages even though my robots.txt file says to deny access to all robots.  Apparently some crawlers don’t respect that signal.

For a little background, I did publish some basics about doing transforms here:

https://peterkellner.net/2013/03/31/vs2012-web-deploy-using-tranforms-for-connection-string-in-production/

So, here is what I have in my web.config file that is part of my normal project source control.

image

And, here is my transform file (Web.Test.config)

image

And, just to show the result, this is what end up on my test server:

image

And Finally, just for some extra bonus stuff here at the end, here is what my tranformation looks like that simply removes the debug option when I publish to production.

image