views:

17

answers:

1

Hi All!

While working on ASP.NET MVC 2 web site I faced to the following problem. I need to render speacial script on site's master page for Google analytics when building solution for production, but for debug and test builds this script should not be rendered. I've tried to find a way to make it automatically, but was not succeded in finding a solution.

The only idea I have is create a batch file that will append necessary script into the page before production build and remove after. But I wonder is there any better solution to solve this problem?

A: 

You should be able to use preprocessor directives

#if !DEBUG
               //render code here
#else
              //render something else
#endif

http://msdn.microsoft.com/en-us/library/ed8yd1ha(v=VS.100).aspx

Ed B