Results 1 to 6 of 6

Thread: How ASP.NET MVC Works

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    How ASP.NET MVC Works

    I am following the article tr333 recommended here

    Has anybody walked through the article? I am here http://www.howmvcworks.net/GettingStarted/CreatingAView and on step 3 below:

    Step 3: Create a Controller Action for the View
    So now I have my view. I now need to tell its controller to return it when visiting the proper url. So I go to my "ZooController" and added the following:


    public ActionResult LookAtTheMonkey()
    {
    return View();
    }

    Now that this is done, if you go to "/Zoo/LookAtTheMonkey" you will get a rather bland page...but a page nonetheless.


    When he says, "if you go to '/Zoo/LookAtTheMonkey'..." go to it how? If I hit go it says the resource or one of its dependencies isn't found, but the page is right here in Views/Zoo:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    LookAtTheMonkey
    </asp:Content>

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>LookAtTheMonkey</h2>

    </asp:Content>
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,522

    Re: How ASP.NET MVC Works

    When he says, "if you go to '/Zoo/LookAtTheMonkey'..." go to it how?
    by using your web browser... it should be something along the lines of http://yourservername/Zoo/LookAtTheMonkey ...
    as shown here in their example online: http://www.howmvcworks.net/Zoo/LookAtTheMonkey <-- how they "went to /Zoo/LookAtTheMonkey"?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,475

    Re: How ASP.NET MVC Works

    One would think so. But that is exactly what I am trying and I am getting resource or dependency not found. If I try http://localhost:nnnnn/Zoo/LookAtTheMonkey.aspx or http://localhost:nnnnn/Views/Zoo/LookAtTheMonkey.aspx -- Oh, I needed to leave off the .aspx extension. This worked: http://localhost:nnnnn/Zoo/LookAtTheMonkey!!! Thanks for the prompt to keep trying.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,522

    Re: How ASP.NET MVC Works

    yeah... it says to go to zoo/lookatthemoneky ... not lookatthemonkey.aspx ... I didn't realize that's what you were doing.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: How ASP.NET MVC Works

    Going to "/Zoo/LookAtTheMonkey" means that you want to call the LookAtTheMonkey action inside the Zoo controller. If you look in your global.asax file, you will see the default route mapping defined in RegisterRoutes() which is "{controller}/{action}/{id}" with the "id" paramater being optional. The great thing about this is you can specify any type for the "id" parameter (if it has a string representation) like string/int/Guid/etc. when you create your action methods.

    That site also appears to be quite old, but is still useful for teaching the MVC concepts.

    If you are starting out on MVC, I would recommend using the razor view engine instead of the "aspx" view engine. It's got a much cleaner/nicer layout than "aspx" views.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  6. #6
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: How ASP.NET MVC Works

    Quote Originally Posted by tr333 View Post
    If you are starting out on MVC, I would recommend using the razor view engine instead of the "aspx" view engine. It's got a much cleaner/nicer layout than "aspx" views.
    I would have to agree with this. You will find it quite jarring to start with, but it is quickly becoming the default View Engine.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width