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

后端 未结 8 1578
梦谈多话
梦谈多话 2020-11-28 12:28

A portion of our site is done in PHP and a portion of our site is done in ASP.Net. We just set up a new web server with Windows Server 2008 R2 which has IIS 7.5 installed.

相关标签:
8条回答
  • 2020-11-28 13:05

    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

    0 讨论(0)
  • 2020-11-28 13:10

    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

    0 讨论(0)
  • 2020-11-28 13:14

    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/*

    0 讨论(0)
  • 2020-11-28 13:16

    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.

    0 讨论(0)
  • 2020-11-28 13:20

    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.

    0 讨论(0)
  • 2020-11-28 13:21

    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.

    0 讨论(0)
提交回复
热议问题