Is ASP.NET MVC completely (and exclusively) based on conventions?

–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 butnot 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.)

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.

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.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật