I've inherited a pre-compiled website that uses javascript created in a generic handler (ashx). I need to modify the js, but I dont have the source, only the pre-compiled libraries. Currently, we're simply doing an http request on the ashx, modifying the result and then outputting it directly on the site:
<script runat="server">
protected string getJs()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(Request.Url, "/js.ashx"));
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
return = sr.ReadToEnd().Replace("old stuff", "new stuff");
}
</script>
<script type="text/javascript">
<%= getJs() %>
</script>
This seems like a pretty round-about way of doing this. Is there anyway to modify the output of a generic handler without requesting the page itself?