Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 823405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:56:33+00:00 2026-05-15T02:56:33+00:00

While trying to implement the second answer to a previous question , I am

  • 0

While trying to implement the second answer to a previous question, I am receiving an error.

I have implemented the methods just as the post shows, and the first three work properly. The fourth one (HomeController_Delete_Action_Handler_Should_Redirect_If_Model_Successfully_Delete) gives this error: Could not find a parameter named ‘controller’ in the result’s Values collection.

If I change the code to:

actual 
    .AssertActionRedirect() 
    .ToAction("Index");

it works properly, but I don’t like the “magic string” in there and prefer to use the lambda method that the other poster used.

My controller method looks like this:

    [HttpPost]
    public ActionResult Delete(State model)
    {
        try
        {
            if( model == null )
            {
                return View( model );
            }

            _stateService.Delete( model );

            return RedirectToAction("Index");
        }
        catch
        {
            return View( model );
        }
    }

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T02:56:34+00:00Added an answer on May 15, 2026 at 2:56 am

    MVCContrib.TestHelper expects you to specify the controller name when redirecting in the Delete action:

    return RedirectToAction("Index", "Home");
    

    Then you would be able to use the strongly typed assertion:

    actual
        .AssertActionRedirect()
        .ToAction<HomeController>(c => c.Index());
    

    Another alternative is to write your own ToActionCustom extension method:

    public static class TestHelperExtensions
    {
        public static RedirectToRouteResult ToActionCustom<TController>(
            this RedirectToRouteResult result, 
            Expression<Action<TController>> action
        ) where TController : IController
        {
            var body = (MethodCallExpression)action.Body;
            var name = body.Method.Name;
            return result.ToAction(name);
        }
    }
    

    which would allow you to leave the redirect as is:

    return RedirectToAction("Index");
    

    and test the result like this:

    actual
        .AssertActionRedirect()
        .ToActionCustom<HomeController>(c => c.Index());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to AS3 and I'm getting this error while trying to implement OO
While trying to write an answer for another SO question something really peculiar happened.
I'm trying to implement a time limit a user has to answer a question
I am new to gaming apps. I am trying to implement question and answer
While trying to implement an MVC file upload example on Scott Hanselman's blog. I
While trying to find an answer to Android Jasper Reporting I found out that
As I mentioned in this question, I am trying to implement a feature in
I am trying to implement 'volume automation' in a jQuery audio player I have
I'm trying to implement a hasone relationship between 2 models, but I can't have
I was trying to solve this Project Euler Question . I implemented the sieve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.