4

Forgive me for my ignorance on this subject, but I'm a relatively seasoned php programmer who's had no experience in any other Web programming languages, except some Ruby.

I've been told some time ago that ASP and ASP.NET are somewhat equivalent to PHP since they perform basically the same tasks,i.e. handle post and get requests, can print html, access a database, and so on.

So if they're similar and in PHP I can basically do everything I need for a web app, what is the need then for another language in the Microsoft Stack, namely C#??

If I'm not mistaken, C# is one of the most sought-after language here at SO, so I'm guessing I'm missing something big here.

Could I have some clarification? Thanks in advance

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Felipe
  • 11,557
  • 7
  • 56
  • 103

6 Answers6

5

Ok, there are 3 layers involved here.

  1. C# <- This is a raw programming language. It can be used alone just like any other language. This would be roughly equivalent to PHP, Ruby, Perl, etc

  2. .NET <- This is a framework for natively interacting with libraries from any supported language. Without .NET, if you wanted to use a VB class in a C# application, you would need to build some kind of interface (such as a RPC via network, or a command-line wrapper, etc). With .NET, you can directly interact with a VB.NET class just how you would with other C# classes (and data, etc). Basically, it makes it easier to integrate multiple languages. There is no equivalent in PHP...

  3. ASP <- This is a framework for building web-based applications. Remember, C# and VB are (for lack of a better term) generic languages. There's nothing in-built to the language for dealing with websites. So ASP adds a layer ontop to make creating websites far easier (request handling, MVC libraries, etc). This is similar to the framework concept in PHP (such as Zend Framework).

Now, there are 2 versions of ASP. The old version (known as Classic ASP) and the new one (ASP.NET). The difference is that ASP.NET is built on top of the .NET framework. So using ASP.NET allows you to make web sites with your language of choice (as long as it has a .NET binding, such as C# or VB.NET, etc).

ASP.NET and .NET are nothing more than layers on top of an existing programming language (C# in this case, but many others are also supported). They are there to make your life easier. Everything they do can be done in straight C#, but the framework is there to abstract away the common themes and let you focus on your problem (like any good framework)...

ircmaxell
  • 163,128
  • 34
  • 264
  • 314
1

ASP.NET is a web development framework that you can interface with using C#(or VB.NET).

C# is just a language that as implemented for .NET

Achilles
  • 11,165
  • 9
  • 62
  • 113
  • Yeah but doesn't asp have all the logic you need, like PHP? Why do I need another programming language(C#)? – Felipe Feb 15 '11 at 22:29
  • 5
    ASP is NOT a programming language. C# is. ASP is a name for the platform/API. – Emond Feb 15 '11 at 22:32
  • NOT a Programming language? What's this then? <% response.write("My first ASP script!") %> I'm not being sarcastic btw, I really don't know – Felipe Feb 15 '11 at 22:37
  • The code you posted above is not C#, it contains bits of it, but this are ASP.NET tags which are used in conjunction with pure html. What is more with C# you can do much, much more than just use ASP.NET. – kubal5003 Feb 15 '11 at 22:39
  • 2
    That's an ASP web page, with server-side script written in the VBScript programming language, embedded within HTML. That script calls the ASP Response class, which outputs the string to the HTTP response stream. VBScript code can execute in different runtime environments, like the Windows command shell. – Matt Crouch Feb 15 '11 at 22:43
1

PHP and asp/asp.net are similar in that aspect..but when it comes down to site implementation, they are very different.. In PHP, you can integrate php code with html, making it super easy to make dynamic web pages. asp.net on the other hand is basically MS's easy way to create html, and place and implement server side and client side script/code easily. You need to know C# or VB in order to implement .NET server side code.

Nick Rolando
  • 25,879
  • 13
  • 79
  • 119
1

Like Achilles said, ASP.NET is a framework that has a lot of fun features and so forth. It is not a language. You do not write things in .NET or ASP.NET. You write code using one of the .NET-friendly languages, such as C#.

As an example of the difference, you may choose to bypass .NET altogether and write your C# code against the Mono project, which is a .NET-like framework but not from Microsoft.

To further clarify, you may write aspx pages, but you will be using a combination of HTML and ASP.NET server controls, or as the case may be if using MVC, you will be using a combination of HTML and C# code on this aspx page.

MrBoJangles
  • 12,127
  • 17
  • 61
  • 79
1

I think you're confusing some things.

There is ASP - often refered to now as Classic ASP. This is a dynamic, PHP like, web language. PHP and Classic ASP are very similar.

There is ASP.Net, which relies on an underlying language like C# or Vb.net.

As for your question as to why choose one or the other:

PHP/Classic ASP vs. ASP.Net:

.NET & ASP vs PHP

http://www.beansoftware.com/ASP.NET-Tutorials/Classic-ASP-vs-ASP.NET.aspx

Community
  • 1
  • 1
brendan
  • 29,308
  • 20
  • 68
  • 109
  • Soo... The piece of code I've copypasted in the other answer ( <% response.write("My first ASP script!") %> ) is what you have called Classic ASP? – Felipe Feb 15 '11 at 23:03
  • @Felipe No, its not. <% %> are inline code tags that can be embedded in an html page. The code between the tags is whatever language you register at the top of your html page as 'Page Language', in your case, that is probably VBscript. Once again, ASP is NOT a language. It is more like an engine that parses your ASP pages which hold html and whatever other code you specify. You really chose the wrong solution as the answer, no offense. That first hyperlink isn't even the same title as the actual page. That's misleading. http://msdn.microsoft.com/en-us/library/ms178135%28vs.80%29.aspx – Nick Rolando Feb 15 '11 at 23:21
0

for writing asp.net page you need a language like C# or vb.net.

Student
  • 3,469
  • 7
  • 35
  • 42