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 7545559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:57:43+00:00 2026-05-30T08:57:43+00:00

I am learning ASP MVC , thus new to TDD and MVC frameworks. I

  • 0

I am learning ASP MVC , thus new to TDD and MVC frameworks. I find an issue while writing mock TestMethod for testing a Action inside the Controller, that ” RedirectToAction” in its body.

Writing the testMethod to make sure the redirected Action is correct. I read it’s possible to check with RedirectToRouteResult.RouteValues, and getting value for “action” key. Even in debug (watching down to the properties) I am able to get it correct. But @ compile time the test is showing exception Cannot apply Indexing with [] to an expression of type RedirectToRouteResult.RouteValues.

Following is the code snippet for the reference:

public void TestHomeControllerContactRedirectRoute()
        {
            HomeController controller = new HomeController();
            ContactMessage message=new ContactMessage(){

                Email="abc@xyz.com",
                MessageBody="Some message here!!",
                Name="Sun"
            };

            RedirectToRouteResult resultRoute = controller.Contact(message) as RedirectToRouteResult;

            if (resultRoute != null)
            {

                Assert.AreEqual("Contact", resultRoute.RouteValues["action"]);
            }
        }
  • 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-30T08:57:45+00:00Added an answer on May 30, 2026 at 8:57 am

    Potentially missing a reference to System.Web

    Source: http://samritchie.net/2011/01/06/mvc-unit-testing-error/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm kind of new to the .NET platform. And currently I'm learning ASP.NET MVC.
i'm just learning to put in unit testing for my asp.net mvc when i
I am still learning ASP.NET MVC. With webforms, I would create a new folder
I am learning ASP.NET MVC. I started reading MVC in Action and Pro ASP.NET
I've been learning asp.net mvc 3. So, basically I'm trying to create a new
I am new to asp.net MVC, using MVC4 at the moment, learning by tutorials
I'm learning ASP.NET MVC and bugged by one issue. In the HomeController, the Index
I’m just learning ASP.NET MVC and I’m trying to create a mock form request
Where can I find a good tutorial on learning ASP.NET MVC using VB.net 2008
I am learning ASP.NET MVC now a days and I have found that most

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.