I have an application which injects dynamically created javascript into a literal control in my master page.
Is there any way to render this dynamic javascript in a javascript file? I'd prefer to just stream it to the client, not save the file to disk, then add a reference to the file in my HTML. Not sure thats possible after searching for a while.
I don't think I can accomplish this in the manner I'd like. My goal is to not persist the dynamically created javascript file (session, file system etc). Instead, I was hoping to stream the javascript file to the client in the same response that the page
is sent. Once the render event of the page has executed, I'd like to have no persisted java script file.
The problem is that the response can only be 1 resource (as far as I know) at a time. This means I'd need to send the page response, with a link to reach back and request the persisted dynamically built javascript file.
This isn't a hard requirement, I was just playing around to see if it would work.
pardo
Member
322 Points
105 Posts
Dynamically render javascript to .js file and send to client
Feb 24, 2012 04:13 PM|LINK
Hello!
I have an application which injects dynamically created javascript into a literal control in my master page.
Is there any way to render this dynamic javascript in a javascript file? I'd prefer to just stream it to the client, not save the file to disk, then add a reference to the file in my HTML. Not sure thats possible after searching for a while.
Thanks!
Pardo
roopeshreddy
All-Star
20155 Points
3328 Posts
Re: Dynamically render javascript to .js file and send to client
Feb 25, 2012 01:34 AM|LINK
Hi,
It is not possible! As of now you can render it to the page itself!!!
Hope it helps u...
Roopesh Reddy C
Roopesh's Space
A1ien51
All-Star
29935 Points
5821 Posts
Re: Dynamically render javascript to .js file and send to client
Feb 25, 2012 01:55 AM|LINK
Make an ashx handler and spit out the JavaScript. Set content type to
pardo
Member
322 Points
105 Posts
Re: Dynamically render javascript to .js file and send to client
Feb 27, 2012 11:42 AM|LINK
Alien51,
That was the gentle nudge I was looking for. Thanks and I'll mark this as the answer once I get it working.
pardo
Member
322 Points
105 Posts
Re: Dynamically render javascript to .js file and send to client
Feb 27, 2012 01:11 PM|LINK
I don't think I can accomplish this in the manner I'd like. My goal is to not persist the dynamically created javascript file (session, file system etc). Instead, I was hoping to stream the javascript file to the client in the same response that the page is sent. Once the render event of the page has executed, I'd like to have no persisted java script file.
The problem is that the response can only be 1 resource (as far as I know) at a time. This means I'd need to send the page response, with a link to reach back and request the persisted dynamically built javascript file.
This isn't a hard requirement, I was just playing around to see if it would work.
Thanks!