Reputation: 1
I have C# asp.net framework Visual Studio solution. The .aspx/.ascx files do have a script tag written. Since we use a minified mechanism outside of Visual Studio, minified files are being referenced on the pages. e.g.
The problem is that whenever I want to debug, I need to remove the .min from the script tag so that the non-minified file is rendered.
The problem is, that developers often forget to put the .min back to the .aspx/.ascx files, and then the non-minified files get rendered in non-prod and prod environments. I am looking for a solution, where I can remove the .min.js from the script file, whenever the web project runs in the DEBUG configuration, so that -developers do not have to make this change and later forget to put the .min back into the code base. So, in theory, this is what I am trying to achieve
In the DEBUG configuration, I should have the script tag to be <script src=abc.js></script> I think it can be done with some sort of code behind the code to insert the entire script tag. I do not think I can go with RegisterStartUpScript part, as I have files in MVC as well.
tried if I can perform a code-behind C# code to insert a script tag, could not succeed.
Upvotes: 0
Views: 35
Reputation: 672
If you're just trying to vary the name of the script based on if a debugger is attached or not you can try this approach:
<script src="<%=(System.Diagnostics.Debugger.IsAttached ? "abc.js" : "abc.min.js")%>"></script>
Upvotes: 0