Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

--TL;DR

  • Is there a "Hello World!" ASP.NET MVC tutorial out there that doesn't rely on conventions and "stock" projects?
  • Is it even possible to take advantage of the technology without reusing the default file structure, and start from a single "hello_world.asp" file or something (like in PHP)?
  • Am I completely mistaken and I should be looking somewhere else, maybe this?
  • I'm interested in the MVC framework, not Web Forms

--Background

I've played a bit with PHP in the past, just for fun, and now I'm back to it since web development became relevant for me once again. I'm no professional, but I try to gain as much knowledge and control over the technology I'm working with as possible.

I'm using Visual Studio 2012 for C# - my "desktop" language of choice - and since I got the Professional Edition from Dreamspark, the Web Development Tools are available, including ASP.NET MVC 4. I won't touch Web Forms, but the MVC Framework got my attention because the MVC pattern is something I can really relate to, since it provides the control I want but... not quite.

Learning PHP was easy - and right form the start I could just create a "hello_world.php" file and just do something like this for immediate results:

<!-- file: hello_world.php -->
<?php>
    echo "Hello World!";
<?>

But I couldn't find a single ASP.NET (MVC) tutorial out there (I'll be sure to buy one of the upcoming MVC 4 books, only a month away or so) that would start like that. They all start with a sample project, building up knowledge from the basics and heavily using conventions as they go along. Which is fine, I suppose, but it's now the best way for me to learn things.

Even the "Empty" project template for a new ASP.NET MVC 4 Application in VS2012 is not empty at all: several files and folders are created for you - much like a new C# desktop application project, but with C# I can in fact start from scratch, creating the project structure myself.

It is not the case with PHP:

  • I can choose from a plethora of different MVC frameworks
  • I can just create my own framework
  • I can just skip frameworks altogether, and toss random PHP along with my HTML on a single file and make it work

I understand the framework needs to establish some rules, but what if I just want to create a single page website with some C# logic behind it? Do I really need to create a whole bloat of files and folders for the sake of convention?

Also, please understand that I haven't gotten far on any of those tutorials mainly because of this reason, but, if that's the only way to do it, I'll go for it using one of the books I've mentioned before. This is my first contact with ASP.NET but from the few comparisons I've read, I believe I should stay the hell away from Web Forms.

Thank you. (Please forgive the broken English - it is not my primary language.)

share|improve this question
2  
don't hate on webforms, they work great for many types of sites, they just aren't in vogue with the recent design fads. –  Ryathal Oct 1 '12 at 14:19
    
@Ryathal It's not that they don't work, I know they do! It's just that - at a first glance - it seems you give up a lot of control when dealing with them. But of course I'll learn about them, too. –  Mike Valeriano Oct 1 '12 at 15:52
add comment

2 Answers 2

EDIT: To summarise, I think understand where you're coming from - at first glance, the ASP.Net MVC framework seems to have (too) many parts, and it's difficult to start understanding it. Having said this, I'd argue that you're looking at this wrong. ASP.Net MVC is not a particularly heavy MVC framework (you should compare it to PHP MVC frameworks to be fair), but yes, it is very much conventions-based. There is a lot of good reasoning behind that design choice, and your first priority in learning the framework would be to learn its conventions, and perhaps the reasoning for them. If for some reason you absolutely want to go deeper, the framework is open source, and you can dig into it here.

I can just skip frameworks altogether, and toss random PHP along with my HTML on a single file and make it work

Well, not with an MVC framework (even in PHP). You're going to at least have a model, a view, and a controller. Those are a bit of a minimum, so I'm not really sure what you're looking for here; it's an apples and oranges comparison.

After that, there's going to be a few other files that you will probably need; such as configuration for the routing, etc. This is fairly standard and comparable to PHP MVC frameworks.

If you want a "single page" model, you could try WebForms, although that technology typically tries to move logic into a separate "code behind" page. I'm pretty sure you could skip the latter, however, and have .aspx files logically identical to .php files sitting there.

Do I really need to create a whole bloat of files and folders...

The default VS project template does tend to copy a lot of potentially unnecessary stuff (scripts, etc), but you could remove most of those. Again, you will probably have a minimum number of things there. Do these really cause you major worry? Have you seen what a Symfony installation looks like?

... for the sake of convention?

Convention is a great thing. The concept is called "convention over configuration", and for most non-trivial projects, it is wonderful thing. It stops people from reinventing things, and gives standards that should be followed.

Since you mention this is a learning exercise, I would suggest that you stop worrying about these things too much. ASP.Net MVC is very much about convention, and you are doing yourself a disservice by trying to work around those. In fact, to learn MVC, you should learn the conventions as much as any of the internals.

share|improve this answer
add comment

If you are looking for simple C# backed pages, look into ASP.NET Web Pages. These are designed to be "framework-less" type way of building ASP.NET MVC style web applications, like would be done in raw PHP.

The full ASP.NET MVC framework does rely heavily on conventions, but it is itself a framework, not "raw" ASP.NET.

share|improve this answer
    
Conventions in ASP.NET MVC are just that: conventions. They can all be overridden, or the convention can be explicitly stated in the code to make it more obvious what is happening. –  Robert Harvey Oct 1 '12 at 14:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.