Can PHP and ASP.Net run together within the same web site in IIS 7.5?

百般思念 提交于 2019-11-26 22:50:06

You should be able to run both in the same site, but be sure that the AppPool for the site runs a "classic" ASP.NET pool configuration. The default AppPool routes everything through ASP.NET, and you won't want that for your PHP pages.

Other than that, you should be fine. Query strings, files, and back-end databases will be the best way to share data between pages.

Yes you can use both under the same website. Since the file extensions are mapped to specific external processes, they are called independently. You can even use Asp.Net to secure .php files with FormsAuthentication by implementing wildcard mappings within IIS (I know 6/7 have this, not sure about 5). Mixing data across them is tricky because they will have separate external processes and thus separate sessions. Most cookies will be readable across both, but secured cookies will not be.

Yes you can, but watch out for this:

If you have a wordpress on your "root", and asp.net apps in folders under it

(e.g. http://root.com/aspnetapp1/), and if you follow these suggestions about "urlrewrite" for permalinks in wordpress, you can have trouble if you try to configure "wildcard handlers" in the apsnetapp1.

To avoid issues, the web.config of the wordpress root app must also have that setting:

    <location path="." inheritInChildApplications="false"> 
    <system.webServer>
...
    </system.webServer>
</location>

Or else, your wildcard handler will never raise because index.php from root will catch all your requests to url like: http://root.com/aspnetapp1/api/*

Yes, PHP can be seamlessly implemented into ASP.NET 3.5 / 4.0

Go to http://phalanger.codeplex.com/ (or http://www.php-compiler.net/) and download the latest version of Phalanger. Install into Visual Studio and voila!

Phalanger – the PHP compiler for .NET

Welcome to Phalanger – full-featured PHP runtime & compiler for .NET/Mono frameworks. Phalanger is modern open-source implementation of PHP, compatible with the vast array of existing PHP code. In addition Phalanger gives PHP-application developers lot of new possibilities; from improving performance and using modern environments, to taking advantage of seamless unique .NET integration.

Yes, it will be not a problem. Even some Windows Shared Hosts offer PHP plans - Windows Hosting PHP.

ASP and PHP can be used on windows boxes. As long as they're completely separate and aren't dependent on each other. For example, using query strings (i.e file.php?var=1&var2=bla) things get messy when you need to transfer those variables over to the ASP file or vice versa.

So as long as the 2 systems are totally independent of each other, then it should work fine.

You may also find some incompatibility with cookies and sessions. Those too can be passed but not easily.

ASP.NET and PHP Support

Develop, deploy and easily manage Web applications using your choice of languages. From ASP.NET to PHP, IIS7 provides a powerful and flexible Web server environment for the world’s most popular Web applications.

(Source: http://www.iis.net/overview/choice/aspnetandphpsupport )

I tried put a test.php file (with conent: <?php phpinfo(); ?> ) to existing ASP.NET website (use real server at https://somee.com ). I knew that ASP.NET and PHP have worked together.

Read more:
http://www.w3schools.com/aspnet/webpages_php.asp
https://technet.microsoft.com/en-us/library/hh994592.aspx

davidbcn

You can run both on the same site, but won't be able to talk to each other unless you setup some sort of messaging system or share storage.They are basically applications of complete different nature.

Another possibility is to call your .NET code from PHP:

A piece of code written in C# like this:

string javascript = "";
Microsoft.Ajax.Utilities.Minifier m = new Microsoft.Ajax.Utilities.Minifier();
Microsoft.Ajax.Utilities.CodeSettings settings = new Microsoft.Ajax.Utilities.CodeSettings();
settings.OutputMode = Microsoft.Ajax.Utilities.OutputMode.SingleLine;
settings.PreserveFunctionNames = false;
string minified = m.MinifyJavaScript(javascript, settings);

Will look like this on PHP:

$minifier = netMinifier::Minifier_Constructor();
$settings = netCodeSettings::CodeSettings_Constructor();
$csssettings = \ms\Microsoft\Ajax\Utilities\netCssSettings::CssSettings_Constructor();
$settings->OutputMode(\ms\Microsoft\Ajax\Utilities\netOutputMode::SingleLine());
$settings->PreserveFunctionNames(FALSE);
$settings->QuoteObjectLiteralProperties(TRUE);
$result = $minifier->MinifyStyleSheet($css, $csssettings, $settings)->Val();

From:

http://www.drupalonwindows.com/en/blog/calling-net-framework-and-net-assemblies-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!