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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:27:49+00:00 2026-05-23T01:27:49+00:00

Meta note: it is impossible to search for the word this. I’ve just run

  • 0

Meta note: it is impossible to search for the word “this”.

I’ve just run into a strange scenario in ASP.NET where the this keyword is required. But it’s not for the purpose of resolving between local and instance variables, as you would see in a constructor.

Microsoft.Web.Mvc contains a class called ControllerExtensions, and I’m using the RedirectToAction(Expression<Action<TController>> action) overload. Maybe this is special because the overload is an extension.

RedirectToAction(c => c.Index()) won’t compile, and it says Cannot convert lambda expression to type 'string' because it is not a delegate type. Now this sounds to me like it thinks I’m using the first overload which takes a string.

this.RedirectToAction(c => c.Index()) compiles fine. I can also call it statically, passing this as the first parameter.

  1. Why can’t the compiler figure out that I’m looking for the overload that takes an Expression, and use that? Because the method takes an expression of an action, and not just an action, that must be involved. I don’t understand the Expressions namespace at all, so I don’t know the purpose of using this parameter type.

  2. Regardless of the answer to #1, why does simply adding this fix everything?

  • 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-23T01:27:50+00:00Added an answer on May 23, 2026 at 1:27 am

    Extension methods work this way.

    According to the C# spec (7.6.5.2 Extension method invocations), extension methods are only used if the call has “one of the forms”:

    expr . identifier ( )
    expr . identifier ( args )
    expr . identifier < typeargs > ( )
    expr . identifier < typeargs > ( args )
    

    This basically means you always have to have something on the left of the “.” to have the compiler resolve an extension method. The expr. portion must exist (and not be dynamic) for the compiler to look for an extension method.

    For example, here is a small test that demonstrates:

    namespace TestNamespace
    {
        using System;
    
        public static class TextExtension
        {
            public static void Print(this Test test)
            {
                Console.WriteLine("Found");
            }
        }
    
        public class Test
        {
            public void Foo()
            {
                // Compiler error!
                Print();
    
                // Works fine
                this.Print();
            }
    
            static void Main()
            {
                Test test = new Test();
                test.Foo();
    
                // Fine here
                test.Print();
                Console.ReadKey();
            }
        }
    }
    

    Note the compiler error – since we’re inside of the Test instance, you can’t call Print() directly without using this.. However, we can easily do test.Print() (or this.Print() inside of Test).

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

Sidebar

Related Questions

Is there CSS Meta Framefork for ASP.NET? Something like LESS or xCSS.
We can store Chinese character into mysql table Using this ( meta http-equiv=Content-type value=text/html;
note: question title is change as discussed in this meta Q&A I'm using the
[Meta-note:] I was browsing the question page, getting really tired of DIVS vs Tables
Does filling out HTML meta description/keyword tags matter for SEO?
I'm building an ASP.NET MVC site where I want one of the Views I
[Note: This question had the original title " C (ish) style union in C#
(Note, this is not the double-margin bug. I'm calling this the double-vertical-padding bug for
This is how my site looks so far (Note: I'm kinda trying to teach
In this answer to a Meta question , Jeff states that he has fixed

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.