PHP vs ASP.NET Part 1
Revelations I've Had While Trying To Learn ASP.NET
Thursday, January 27, 2005 by Zoomba | Discussion: Websites
So, I've been trying to learn ASP.NET for the purpose of building this tool. In the short time I've been at this, I've been frustrated by the needless layers of complexity Microsoft introduces into the process of building a dynamic web page. This is the first part in what will likely be a multipart series of articles in which I compare and contrast PHP and ASP.NET. This will be the foundation for a later report I've been asked to write for the head of the Architecture Practice here to show the relative merits of adding PHP to the supported list.
I admit I'm biased here by the fact that I am familiar with one, but not the other. However, I'm going to try and limit my points to items where there is a clear difference between the two... Each of these articles will compare and contrast the two on a specific problem I'm encountering.
1.) How Much Do You Need To Know?
Ok, lets say you want to create the most basic dynamic page. All you want to do is have a form with a text field that you fill in with whatever text you like, and when you click submit, it loads a page that displays that text and nothing more. No databases, nothing complicated. How much do you need to know to do that in either language? Well, let's take a look...
PHP
Languages Needed: PHP, HTML
Solution method: The form page is simple HTML form, all it does is POST to the target php page to display the text. The target PHP page grabs the posted field, assigns it to a variable and prints it to the screen. Lines of code in PHP... 2.
ASP.NET
Langauges Needed: ASP.NET tags, HTML, VB.NET/C#/Whatever your desired .NET language is... so in essence, 3 languages
Solution method: Well, in ASP.NET, you don't POST to other pages, you POST back to the same form, write a button click event that processes the information and assigns it to a variable. Then either redirect everything to a second page, or load the variable as a label somewhere on the original page. Lines of code? Too damn many. I still haven't figured this out properly. I know for damn sure it's a lot more than 2 lines though.
Reply #2 Thursday, January 27, 2005 11:46 AM
test.htm:
#html#
#body#
#form id="boo" name="booo" action="WebForm.aspx"#
#INPUT id="Text1" type="text" name="Text1"# #INPUT id="Submit1" type="submit" value="Submit" name="Submit1"#
#/form#
#/body#
#/html#
WebForm.aspx:
#%@ Page language="c#"%#
#!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" #
#html#
#body#
#%=Request["Text1"]%#
#/body#
#/html#
Reply #3 Thursday, January 27, 2005 11:58 AM
Reply #5 Saturday, January 29, 2005 7:34 PM
Reply #6 Saturday, January 29, 2005 11:11 PM
P.S. Put the connection to the database in the web.config file or leverage 'PostBack' and you only need ONE connection.
Reply #7 Sunday, January 30, 2005 12:27 AM
Reply #8 Sunday, January 30, 2005 12:46 AM
Reply #9 Sunday, January 30, 2005 11:16 AM
Reply #10 Sunday, January 30, 2005 5:38 PM
<?php echo $_POST['form_element_name'] ?>
Only one line, right?
Reply #11 Sunday, January 30, 2005 5:53 PM
Reply #12 Sunday, January 30, 2005 6:53 PM
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!
Reply #1 Thursday, January 27, 2005 11:39 AM
Here is the first page just regular html.
WebForm.aspx:
WebForm