SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)

    Need a second pair of eyes...

    Just ran into an odd error, but unfortunately I cannot access my asp.net forums account to ask.

    In a controller, where I was testing one-shot responses, I get an action ambiguity error.

    Code Csharp:
    [HttpGet]
    public ActionResult MakePreferred(Guid id)
    {
    var customer = customerRepository.GetById(id);
    customer.MakePreferred();
    customerRepository.Update(customer);
    return RedirectToAction("details", new { id = id });
    }
     
    [HttpGet]
    public ActionResult MakeNotPreferred(Guid id)
    {
    var customer = customerRepository.GetById(id);
    customer.MakeNotPreferred();
    customerRepository.Update(customer);
    return RedirectToAction("details", new { id = id });
    }

    The actions are one-shot formless updates, that refer back to the page the link is actually on. The links are built thusly:

    Code ASP:
    @if (Model.IsPreferred)
    {
    @Html.ActionLink("Revoke Preferred Status", "MakeNotPreferred", new { id = Model.Id })
    }
    else
    {
    @Html.ActionLink("Grant Preferred Status", "MakePreferred", new { id = Model.Id })
    }

    As you can see, the action names are completely different, as well as the links, so why am I getting ambiguity errors?

  2. #2
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I've seen the exact same thing as you, they are different. What about the rest of your code for this task?

  3. #3
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    SerenaRules, then you figure out what the problem was?

  4. #4
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    Not really, thought it's fixed now. All I did was rename them Foo and Bar, then renamed them back. It started working after that. Very odd. It's beats all I've ever seen.

  5. #5
    SitePoint Guru pufa's Avatar
    Join Date
    Oct 2004
    Location
    Portugal, Lisboa
    Posts
    947
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are using a GET request... and the browser is caching the first response!
    Just a thought...

    Disable browser caching (in the browser) and see if the problem persists
    Ciao, Rui...

  6. #6
    Resident OCD goofball! bronze trophy Serenarules's Avatar
    Join Date
    Dec 2002
    Posts
    1,911
    Mentioned
    26 Post(s)
    Tagged
    0 Thread(s)
    You might be right, but it's never happened before. The thing is, with different names, it's no different than having the get attribute on Index() and Add(). Oh well, moving along.


Bookmarks

Posting Permissions

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