Results 1 to 9 of 9

Thread: [RESOLVED] What are those errors/How do I fix them

Threaded View

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] What are those errors/How do I fix them

    Hi,

    I finished my advanced C# case study for school although, when I click on either the "Create new" or "Remove from cart" links I receive the following error:

    Server Error in '/' Application.
    The resource cannot be found.
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /ShoppingCart/RemoveFromCart/116

    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225

    I take it that the above message is referring to the ShoppingCartController and the "RemoveFormCart" is the method is is referring to? What about the 116? However, checking the "Controllers" folder there is a file called "ShoppingCartController.cs" it with a method RemoveFromCart inside the file.

    asp Code:
    1. //AJAX: /ShoppingCart/RemoveFromCart/5
    2.         [HttpPost]
    3.         public ActionResult RemoveFromCart(int id)
    4.         {
    5.             //Remove the item from the cart
    6.               var cart = ShoppingCart.GetCart(this.HttpContext);
    7.  
    8.               //Get the name of album to display the confirmation
    9.               string albumName = StoreDB.Carts.Single(item => item.RecordId == id).Album.Title;
    10.  
    11.             //Remove from cart. Removing all for simplicity
    12.               cart.RemoveFromCart(id);
    13.  
    14.             //Display the confirmation message
    15.             var results = new ShoppingCartRemoveViewModel
    16.             {
    17.               Message = Server.HtmlEncode(albumName) + " has been removed from your shopping cart.",
    18.               CartTotal = cart.GetTotal(),
    19.               CartCount = cart.GetCount(),
    20.               DeleteId = id
    21.             };
    22.             return Json(results);
    23.         }

    Here is the shoppingcart index page:

    asp Code:
    1. <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcMusicStore.ViewModels.ShoppingCartViewModel>>" %>
    2.  
    3. <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    4.     Shopping Cart
    5. </asp:Content>
    6.  
    7. <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    8.  
    9. <script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
    10. <script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    11. <script src="/Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    12.  
    13. <script type="text/javascript">
    14.     function handleUpdate(context) {
    15.         //Load and deserialize the returned JSON data
    16.         var json = context.get_data();
    17.         var data = Sys.Serialization.JavaScriptSerializer.deserialize(json);
    18.  
    19.         //Update the page elements
    20.         $('#row-' + data.DeleteId).fadeOut('slow');
    21.         $('#cart-status').text('Cart(' + data.CartCount + ')');
    22.         $('#update-message').text(data.Message);
    23.         $('#cart-total').text(data.CartTotal);
    24.     }
    25. </script>
    26.  
    27.     <h3><em>Review</em> Your cart:</h3>
    28.     <p class="button">
    29.     <%:Html.ActionLink("Checkout >>", "AddressAndPayment", "Checkout") %>
    30.     </p>
    31.     <div id="update-message"></div>
    32.     <table>
    33.         <tr>
    34.             <th>Album Name</th>
    35.             <th>Price (each)</th>
    36.             <th>Quantity</th>
    37.             <th></th>
    38.         </tr>
    39.  
    40. <% var cart = (MvcMusicStore.ViewModels.ShoppingCartViewModel)ViewData["cart"];
    41.     foreach (var item in cart.CartItems ) { %>
    42.    
    43.     <tr id="row-<%: item.RecordId %>">
    44.     <td>
    45.     <%:Html.ActionLink(item.Album.Title, "Details", "Store", new  { id = item.AlbumId}, null)%>
    46.     </td>
    47.     <td>
    48.     <%:item.Album.Price %>
    49.     </td>
    50.     <td>
    51.     <%: item.Count %>
    52.     </td>
    53.     <td>
    54.     <%: Ajax.ActionLink("Remove from cart", "RemoveFromCart", new { id = item.RecordId }, new AjaxOptions { OnSuccess = "handelUpdate" })%>
    55.     </td>
    56.     </tr>
    57.     <% } %>
    58.     <tr>
    59.     <td>Total</td>
    60.     <td></td>
    61.     <td></td>
    62.     <td id="cart-total">
    63.     <%: cart.CartTotal %>
    64.     </td>
    65.     </tr>
    66.     </table>
    67.  
    68.     <p>
    69.         <%: Html.ActionLink("Create New", "GetCart")%>
    70.     </p>
    71.  
    72. </asp:Content>

    So what exactly is it saying it can not find and how do I fix it?

    Thanks,


    Nightwalker
    Last edited by Nightwalker83; Jul 4th, 2011 at 05:11 AM. Reason: Adding more!
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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