[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 606
  • Last Modified:

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

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";
}
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>

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.
0
Kenny Hopton
Asked:
Kenny Hopton
  • 2
  • 2
2 Solutions
 
käµfm³d 👽Commented:
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.
0
 
Kenny HoptonAuthor Commented:
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?
0
 
käµfm³d 👽Commented:
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.
0
 
Kenny HoptonAuthor Commented:
Fast response! Thank you!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now