MVC template web application (C#)... need a roadmap.

Posted on 2014-08-16
Last Modified: 2014-08-16
I used to code for a living so I'm thinking I will build a few web sites and get up to speed on the way things are done now. I did some reading on HTML5, CSS and JavaScript. Follow the instructions in the books, build some stupid example sites that amount to 3 to 5 files, you know the tutorials. Ok, time to do something real.
I have Visual Studio 2013 so I figure I'll start there and lean on the Intellisense crutch until I get a feel. I am trying to find my way around Visual Studio 2013 and, specifically, trying to build a basic MVC web app and get up to speed.
File | New | Project | Templates | Visual C# | Web | ASP.NET Web Application  | MVC ...

Poof!  278 files in 120 folders. Seriously.

I get the MVC concept. I get C#.  I get HTML 101 and CSS 101 and JavaScript 101. But there are a lot of arbitrary modularizations and abstractions in this template that seem to come from thin air.  HTML files are CSHTML files I guess. What is a ViewBag and why is there an @ reference in front of it? If I knew what the @ was I might be able to find documentation for this:

    ViewBag.Title = "Contact";

I have not met this @ and that is a challenge, but there are surely lots of other things like it.  Where can I get an overview of what all the files are for and what these far-from-self-documenting notations are? BTW, I did figure out the $ in JQuery.
Question by:Kenny Hopton
    LVL 74

    Accepted Solution

    The latest versions of ASP.NET MVC use the Razor view engine. Previous versions used the standard Web Forms view engine (which had syntax like <%= something %>). Basically any time you use a @ symbol, you are introducing a code block, which is code that runs on the server, not the client.

    As far as the ViewBag, it's just an object that allows you to share data between views and controllers. ViewBag uses the new dynamic type. dynamic has many uses, but in general it functions similar to the duck-typing you see in interpreted languages like Python and Javascript. One of the down sides to using ViewBag is that you do not get Intellisense support on the what you have stuffed into the ViewBag, so you have to keep track of that yourself (i.e. in your head).

    In regards to a complete reference for all of the files that MVC adds to a project, I don't believe there is a solitary reference. I think you will have to inspect each on a case-by-case basis.

    Author Comment

    by:Kenny Hopton
    Thanks Kaufmed, that was quick and it answered my specific questions getting me back in motion.

    I am still looking for a general roadmap. The secret about files starting with _ being wrappers of a sort, for example. All the secret names like App_Code. I am stumbling over them but I feel like there ought to be a big list so I will be able to tell what all the files in my sample project do. Any idea where I might learn all those arbitrary things?
    LVL 74

    Assisted Solution

    by:käµfm³d 👽
    No. I do not know a general roadmap (someone else might). I usually pick that kind of stuff up as I go.

    I can tell you that App_Code is one of ASP.NET's special folders. Each special folder has a specific intention.

    Also, you are partially correct that the files starting with underscore are wrappers. The _Layout.cshtml file is similar to the master pages that Web Forms uses. The _ViewStart.cshtml file code is used to execute common code that would be executed on any view that is rendered by your application.

    Scott Gu has good information on ASP.NET MVC. Also, the official ASP.NET web site is a very good place to go for in-depth information on MVC and anything else ASP.NET related.

    Author Closing Comment

    by:Kenny Hopton
    Fast response! Thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now