0

I'm writing a ASP.NET web application. It dosen't use Web Forms or MVC. It uses ASP.NET Routing to a Http Handler, and the handler just writes html to the HttpContext.

The final output of my html is something like this:

<html>
<head>
    <title>...</title>
    <script type="text/javascript">
        ...
    </script>
</head>
<body>
    ...
</body>
</html>

Now, Instead of writing the (long) script into this page, I want to write it to another page, and then use the src of script element to reference it. The problem is, that the script is dynamic.

<html>
<head>
    <title>...</title>
    <script type="text/javascript" src="..."></script>
</head>
<body>
    ...
</body>
</html>

Any ideas?

Thanks.

2 Answers 2

3

Can't you just place the location of the dynamic script inside the src?

I.e., if http://www.example.com/foo is your HTTP handler, can you make another HTTP handler, http://www.example.com/bar for the dynamic javascript? You should be able to pass any parameters needed inside a query string.

Sign up to request clarification or add additional context in comments.

Comments

0

your script is dynamic => I assume it changes based on the user/context/date/time ??

you should set your Response.Charset (to UTF-8) & Response.ContentType (to text/javascript)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.