Travis
Travis

Reputation: 659

Adding PHP application to ASP.NET website using master pages

I recently created a website using ASP.NET as I wanted to learn more about this language. I have more recently started learning about PHP and would like to include some php content on this website. I found the VS extension PHP Tools for Visual Studio and thought it might help.

I naively created a PHP page within my previously existing website, and assigned the master page when creating it, called Test.php, and added the master page to this file:

Test.php:

<%@ Page Title="" Language="C#" MasterPageFile="~/Navigation.master" AutoEventWireup="true" CodeFile="Test.php.cs" Inherits="Test" %>

<?php
      echo "Hello World!"; 
?>

but the output is this:

<%@ Page Title="" Language="C#" MasterPageFile="~/Navigation.master" AutoEventWireup="true" CodeFile="Test.php.cs" Inherits="Test" %> Hello World!

so obviously it is not able to properly parse and display this website. I guess as it is using the php extension it has no idea what ASP.NET stuff is doing there. Does anyone have an idea how I can create a php page using this tool that can also be used within the context of master pages?

Upvotes: 0

Views: 328

Answers (1)

Playability
Playability

Reputation: 33

The Microsoft IIS webserver supports PHP so you can create PHP pages (Having the extension .php) that are then interpreted as they would be on Apache. You can't mix and match PHP within other types of file because the script will never get interpreted. Check with your ISP though because not all have PHP enabled.

Upvotes: 1

Related Questions