根据构建类型不同的 ASP.NET 4 页面内容
在开发 ASP.NET MVC 2 网站时,我遇到了以下问题。在构建生产解决方案时,我需要在网站的母版页上呈现特殊脚本以进行 Google 分析,但对于调试和测试构建,不应呈现此脚本。我试图找到一种自动实现的方法,但没有成功找到解决方案。
我唯一的想法是创建一个批处理文件,在生产构建之前将必要的脚本附加到页面中,然后删除。但我想知道有没有更好的方案来解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用预处理器指令
http:// /msdn.microsoft.com/en-us/library/ed8yd1ha(v=VS.100).aspx
You should be able to use preprocessor directives
http://msdn.microsoft.com/en-us/library/ed8yd1ha(v=VS.100).aspx