Search code examples
c#web-servicesasmx

Programmatically get JavaScript generated by *.asmx/js


I'm in the process of creating a build mechanism that will automatically minify and combine a certain set of JavaScripts.

The problem I'm facing is that to actually incorporate these web services, I need to get that content somehow.

I'm aware that it's tentatively possible using the WebClient class and invoking the actual URL, but that feels a bit overkill and would not work when we're triggering this mechanism on Application_Start in Global.asax.

First of all, is it even possible, and if so, and pointers on how I should approach this?


Solution

  • You have two ways:

    1. On-demand combining & minification (outlined by Sohnee) (also check this article.)
    2. Build time - check this article.

    And see previous question on SO for more info:
    Concatenate and minify JavaScript on the fly OR at build time - ASP.NET MVC