1

Brief summary: on a web site hosted on an IIS server, standalone Python files render correctly, but using Python within an .aspx page (as opposed to, say, VB) causes an error, stating that Python is not a supported language, despite having (apparently) registered it with the ActiveX Scripting Engine. I'd like to make Python a supported language.

Further details: I have a web site hosted on an IIS 6.1 server, which can interpret and display .aspx files correctly. I wish to use Python as a language within the .aspx files, rather than VB as I have been up till now.

I've managed to get standalone Python pages to render correctly - for instance, a file on the site that contains the following code:

print 'Content-type: text/html'
print

print '<HTML><HEAD><TITLE>Python Sample CGI</TITLE></HEAD>'
print '<BODY>'
print '<H1>This is a header</H1>'

print '<p>' #this is a comment
print 'See this is just like most other HTML'
print '<br>'
print '</BODY>'

(source) renders correctly, when requested in a web-browser, as

This is a header
See this is just like most other HTML

However, when I try to embed Python code into an .aspx page, such as the following:

<%@ Page Language = "Python" %>
<%
  Response.Write("Python lives in the ASP delimeters!")
%>
<br />

<script language="Python">
document.write("Python's throwing a party on the client-side!")
</script>
<br />

<script language="Python" runat="server">
 Response.Write("Python gets ready to rumble inside a server-side scripting block!")
</script>

(source) I get the following error:

error page

(Note that I've added "Page" in the first line to the example code - I've tried it both with and without, getting the same error both times)

It seems I need to register Python as a language for use in .aspx files. Does anyone have any tips on what I might be missing? I followed all the steps in the 1st link above (although I used ActivePython instead of CPython), which led me to the stage of .py files rendering correctly, but sadly this (otherwise excellent) answer ends there.

I've run C:\Python27\Lib\site-packages\win32comext\axscript\client\pyscript.py, which output "Registered: Python", but C:\Python27\Lib\site-packages\win32comext\axscript\Demos\client\asp\tut1.asp renders as a blank page, instead of the 5 increasingly larger "Hello World"'s I would expect from the source code. I've seen a recommendation here to run pyscript in debug mode, but I can't find how to view the output.

I've also looked at this page on the Microsoft Knowledge Base, which seems somewhat out of date - for instance, several of the descriptions of options/selections have changed names or locations.

EDIT: I've seen suggestions (here, at the bottom, and here ) claiming that the problem is with recent versions of ActivePython. I duly uninstalled ActivePython, downloaded CPython 2.7 and the Win32 Extensions, and went through the whole process again, with the same result - .py files render properly, but attempting to use Python within an .aspx file gives the error "Python is not a supported language".

1 Answer 1

1

I am pretty sure you can't do that. aspx pages are ASP.NET pages which are compiled into .NET assemblies. There is an ASP.NET compiler somewhere that compiles the pages before they run and it only supports .NET languages... even worse it only supports C# and VB.NET (IronPython, F#, etc. are not supported).

I assume you got the idea that this is possible because it may have been possible with the old ASP Classic where maybe (just maybe because I don't know) languages were pluggable but this is not the case with ASP.NET which is entirely different technology and the only thing in common are the letters "ASP" in the name.

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

1 Comment

Gotcha - so I can only use inline Python in .asp files, not .aspx pages? Nevertheless, I'm still having problems: as with this issue, I'm getting 500 Server Errors on simple .asp pages, despite having followed the 3 steps that the answer lists. Any other ideas?

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.