Results 1 to 9 of 9

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

Hybrid 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

  2. #2
    PowerPoster Evil_Giraffe's Avatar
    Join Date
    Aug 2002
    Location
    Suffolk, UK
    Posts
    2,555

    Re: What are those errors/How do I fix them

    Can you post your routes table? Or, indeed, write a test that ensures that URL maps to the expected controller/action? Because you're not generating the link from the controller, it's probably a mismatch there.

  3. #3

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

    Re: What are those errors/How do I fix them

    I have attached my project to the first post so you can see all the errors.
    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

  4. #4
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: What are those errors/How do I fix them

    Can't download the project for restrictions, but are you sure the RemoveFromCart controller has a corresponding view defined?

    The only other problem I can think of right now is the path is incorrect. However I am assuming you have already checked it.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  5. #5

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

    Re: What are those errors/How do I fix them

    Well, I solved the above errors by rewriting the shopping cart index page. Although, now I have another problem:

    Server Error in '/' Application.
    The current request for action 'LogOn' on controller type 'AccountController' is ambiguous between the following action methods:
    System.Web.Mvc.ActionResult LogOn(MvcMusicStore.Models.LogOnModel, System.String) on type MvcMusicStore.Controllers.AccountController
    System.Web.Mvc.ActionResult Logon(MvcMusicStore.Models.LogOnModel, System.String) on type MvcMusicStore.Controllers.AccountController
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Reflection.AmbiguousMatchException: The current request for action 'LogOn' on controller type 'AccountController' is ambiguous between the following action methods:
    System.Web.Mvc.ActionResult LogOn(MvcMusicStore.Models.LogOnModel, System.String) on type MvcMusicStore.Controllers.AccountController
    System.Web.Mvc.ActionResult Logon(MvcMusicStore.Models.LogOnModel, System.String) on type MvcMusicStore.Controllers.AccountController

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [AmbiguousMatchException: The current request for action 'LogOn' on controller type 'AccountController' is ambiguous between the following action methods:
    System.Web.Mvc.ActionResult LogOn(MvcMusicStore.Models.LogOnModel, System.String) on type MvcMusicStore.Controllers.AccountController
    System.Web.Mvc.ActionResult Logon(MvcMusicStore.Models.LogOnModel, System.String) on type MvcMusicStore.Controllers.AccountController]
    System.Web.Mvc.ActionMethodSelector.FindActionMethod(ControllerContext controllerContext, String actionName) +226
    System.Web.Mvc.ReflectedControllerDescriptor.FindAction(ControllerContext controllerContext, String actionName) +182
    System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, String actionName) +47
    System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +283
    System.Web.Mvc.Controller.ExecuteCore() +136
    System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +111
    System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +39
    System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +65
    System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +44
    System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +42
    System.Web.Mvc.Async.WrappedAsyncResult`1.End() +141
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +54
    System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
    System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +52
    System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8920029
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

    when I try to login to the site.

    Edit:

    Never mind! I solved that problem too. I just copied the account login forms, model, etc that I was given back into my project and it fixed the problem.
    Last edited by Nightwalker83; Jul 4th, 2011 at 05:10 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

  6. #6
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Re: What are those errors/How do I fix them

    Quote Originally Posted by Nightwalker83 View Post
    Well, I solved the above errors by rewriting the shopping cart index page. Although, now I have another problem:

    Server Error in '/' Application.
    The current request for action 'LogOn' on controller type 'AccountController' is ambiguous between the following action methods:
    System.Web.Mvc.ActionResult LogOn(MvcMusicStore.Models.LogOnModel, System.String) on type MvcMusicStore.Controllers.AccountController
    System.Web.Mvc.ActionResult Logon(MvcMusicStore.Models.LogOnModel, System.String) on type MvcMusicStore.Controllers.AccountController
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
    It looks like you had two actions with the same name and parameter sets in the controller.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  7. #7

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

    Re: What are those errors/How do I fix them

    Quote Originally Posted by kaneXtreme View Post
    I understand you have fixed your problem. Any workaround that you can suggest me to accomplish this? Was your site running on localhost or an online server when you developed this?
    No, I have only tested the site on the local host not using an online-server.

    Quote Originally Posted by honeybee View Post
    It looks like you had two actions with the same name and parameter sets in the controller.
    Yeah, maybe! I forget now anyway.
    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

  8. #8
    New Member
    Join Date
    Jan 2012
    Posts
    2

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

    Hi there. I'm having the same problem of removing from cart. But i'm having this issue on my production server. On my localhost, it is working fine.

    Anyway, in your shopping cart controller line 12, shouldn't it be like below?

    int itemCount = cart.RemoveFromCart(id);

    I understand you have fixed your problem. Any workaround that you can suggest me to accomplish this? Was your site running on localhost or an online server when you developed this?

  9. #9
    New Member
    Join Date
    Jan 2012
    Posts
    2

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

    Hi again, sorry I missed line 20 on my previous post.

    Line 12; int itemCount = cart.RemoveFromCart(id);
    Line 20; ItemCount = itemCount,

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