Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this code use an .aspx file for JavaScript?

I found some old code which I'm not sure I understand completely. The folowing is an .aspx page containing only JavaScript:

<%@ Page Language="C#" EnableSessionState="True" CodePage="65001" uiculture="auto" %>

<%
Response.ContentType = "text/plain";
%>


var csBackgroundColor;

function testfx() {
    csBackgroundColor.setAttribute('disabled', 'disabled');
}

and it was referenced like this:

<script type="text/javascript" src="filename.js.aspx"></script>

I'm wondering why it wasn't just marked as completely a JavaScript file? Was it done this way so you could include code blocks? With the file this way, I don't even get IntelliSense.

like image 521
Rod Avatar asked Nov 23 '25 13:11

Rod


1 Answers

First time I see something like that but you're right, the reason behind this is to make the file to be processed by the asp.net engine and run it as any other aspx page, giving him the chance to use server side code to build the js file.

If that's all the code in the file, it seems the only objetive was to set the character encoding (CodePage="65001" and the content type (Response.ContentType="text/plain"). It wouldn't make a lot of sense as you can imagine.

like image 149
Claudio Redi Avatar answered Nov 25 '25 03:11

Claudio Redi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!