2
votes

Here is my code

<html>
<body>

<?php
include("Default.aspx");
?>

</body>
</html>

but it keeps giving me the output of

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <% Response.Write("Hello world!"); %>

I just need to run the Hello World on the site.

2
Pick a language and use it. Using ASP and PHP to build the same site like this is rather bizarre.ceejayoz

2 Answers

6
votes

If you want the output of the aspx file, you will need to request it via a web server which can understand aspx files rather than the file system, e.g.

include("http://example.com/Default.aspx");

Your PHP installation must have URL fopen wrappers enabled for this to work.

As Magnus Nordlander notes in another answer, you should only use include if you expect to find php code in the file. If you don't, you could simply use readfile to output the data verbatim:

readfile("http://example.com/Default.aspx");
3
votes

You seem to be going about this in a very wrong way.

What include() (and require(), for that matter) does is that it parses the specified file with the PHP interpreter. If your aspx-code for some reason generates PHP-code, which is supposed to be parsed by the PHP interpreter, then the way Paul Dixon suggests would be the right way of going about this. However, I would strongly advice against doing this.

For one thing, it's a huge security disaster waiting to happen. It's also incredibly bad architecturally speaking.

If you want to include HTML markup etc. generated using aspx, what you should do is to use

echo file_get_contents("http://www.example.com/Default.aspx");

This way, any PHP code in the output remains unparsed, thus avoiding the aforementioned security disaster. However, if you're able to do without mixing languages like this, that's probably going to be a much better solution.