- why the asp.net application run on apache server?
i have created the application in php before the 6 month. now a days little bit modification on that one and client want to change the plateform means that they create whole site in asp.net rather then the php. now i suggest him to we have create some new page in asp.net and continue with the other php pages. in this situation i think that asp.net run on apache server and i try that.
here i give the simple example for that pass the query string value from asp.net to php page and retrive that value and display. php application run as usual.
Steps :
1) Configure Apache Server For Dotnet application.
i have already install the apache server version 2.2.8. i have installed WAMP newer version.
now install the mod_aspdotnet is a loadable Apache 2 module for serving ASP.NET application.
download from http://sourceforge.net/projects/mod-aspdotnet
install the mod-aspdotnet – select installation path is Root Directory Of Apache Server
- why mod-aspdotnet used?
Provides an interface for ASP.NET content between Apache HTTP Server 2.0 and Microsoft’s ASP.NET host.
2) change in the Apached Config File open the (httpd.conf file for Apache server) add the below code
1: #asp.net Module Load Information
2:
3: LoadModule aspdotnet_module "modules/mod_aspdotnet.so"
4:
5: #add handler information
6:
7: AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem
8:
9: resources resx soap vb vbproj vsdisco webinfo
10:
11: <IfModule mod_aspdotnet.cpp>
12:
13: # Mount the ASP.NET /asp application
14:
15: AspNetMount /ASPDOTNETWWWROOT "c:/ASPDOTNETWWWROOT"
16:
17: #/ASPDOTNETWWWROOT is the alias name for asp.net to execute
18:
19: # Map all requests for /asp to the application files
20:
21: Alias /ASPDOTNETWWWROOT "c:/ASPDOTNETWWWROOT"
22:
23: #maps /ASPDOTNETWWWROOT request to "c:/ASPDOTNETWWWROOT"
24:
25: # Allow asp.net scripts to be executed in the /ASPDOTNETWWWROOT example
26:
27: <Directory "c:/ASPDOTNETWWWROOT">
28: Options FollowSymlinks ExecCGI
29: Order allow,deny
30: Allow from all
31: DirectoryIndex index.htm index.aspx
32: #default the index page to .htm and .aspx
33: </Directory>
34:
35: # For all virtual ASP.NET webs, we need the aspnet_client files
36:
37: AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*)
38: "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
39: <Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
40: Options FollowSymlinks
41: Order allow,deny
42: Allow from all
43: </Directory>
44: </IfModule>
45: #asp.net
3) create Folder ASPDOTNETWWWROOT in C:\.
4) create simple asp.net application. here i used link for demo purpose.pass on query string to php page and retrive that.
create phpasp folder in ASPDOTNETWWWROOT Folder.
create below file
4.1) create simple aspx file default.aspx
1: <%@ Page Language="C#" %>
2:
3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4:
5: <script runat="server">
6:
7: </script>
8:
9: <html xmlns="http://www.w3.org/1999/xhtml">
10: <head id="Head1" runat="server">
11: <title>Untitled Page</title>
12: </head>
13: <body>
14: <form id="form1" runat="server">
15: <a href="test1.php?id=1">Registration Page</a>
16: </form>
17: </body>
18: </html>
4.2) create test1.php
1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2: <html xmlns="http://www.w3.org/1999/xhtml">
3: <head>
4: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5: <title>Untitled Document</title>
6: </head>
7:
8: <body>
9: <form action="test2.php" method="post" >
10:
11: <?php
12: echo "Wel Come To World Of Php And Asp.net";
13: echo "Hello, " . $_GET['id'];
14: ?>
15: <table>
16: <tr> <td> Enter First Name </td> <td> <input type="text" name="FirstName" /> </td></tr>
17: <tr> <td> Enter Last Name </td> <td> <input type="text" name="LastName" /> </td></tr>
18: <tr> <td> Enter User Name </td> <td> <input type="text" name="UserName" /> </td></tr>
19: <tr> <td> Enter Password </td> <td> <input type="password" name="Password" /> </td></tr>
20: <tr> <td> Re-Type Password </td> <td> <input type="password" name="RetypePassword" /> </td></tr>
21: <tr><td colspan="2" align="center"><input type="submit" value="Continue"></td></tr>
22: </table>
23: </form>
24: </body>
25: </html>
4.3) create test2.php file
1: <html>
2: <?php
3: $Isok = "false";
4: $UserName = $_REQUEST['UserName'];
5:
6: if(strlen($UserName) > 5)
7: {
8: $Password = $_REQUEST['Password'];
9: $RetypePassword = $_REQUEST['RetypePassword'];
10: if(strcmp($Password,$RetypePassword) !=0)
11: {
12: $Isok = "false";
13: $msg = "Password Not Match";
14: }
15: if(strlen($Password) <3)
16: {
17: $msg = "Password atleast 3 character";
18: $Isok = "false";
19: }
20: }
21: else
22: {
23: $msg = "User Name atleast 5 character";
24: }
25:
26: if($Isok <>"true")
27: {
28: echo "<h2>Wel Come </h2> $UserName";
29: echo "<center>$msg <br> <input type='button' value='Retry' onClick='history.go(-1)'></center>";
30: }
31: else
32: {
33: echo "$msg";
34: }
35: ?>
36:
37: </html>
5) now run the application
http://localhost/ASPDOTNETWWWROOT/phpasp/default.aspx
Click On Registration Link
here you check the query string parameter 1.Click On Continue Button
Thanks.
Ref Site :
1) http://mod-aspdotnet.sourceforge.net/mod_aspdotnet.html