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

  • Home
  • SEARCH
  • 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 8427589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:49:15+00:00 2026-06-10T04:49:15+00:00

I would like to create controller extension method. What I got so far is

  • 0

I would like to create controller extension method. What I got so far is below

public ActionResult Foo()
{
    this.ExtensionMethod();
    return View();
}

public static void ExtensionMethod(this Controller controller)
{

}

What I don’t like is that ExtensionMethod must be called with this keyword. Is it possible to get rid of this?

  • 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-06-10T04:49:16+00:00Added an answer on June 10, 2026 at 4:49 am

    No.

    It is the this keyword that makes the method an extension method. Without it, it’s just a static method.

    Edit: Sorry, I misread the question. There are two this keywords: one in the extension method, and one used to call it.

    The reason you need the this keyword when you call it is that you need to specify the object that is being extended. C# doesn’t automatically resolve local method calls to extension methods unless you specify the this keyword.

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

Sidebar

Related Questions

I would like to create a new controller that will allow the admin user
i would like to create a Rails controller that download a serie of jpg
I would like to create this shape using just css. I am pretty sure
I would like to create set of strings and below is the only limitation.
Can I create a Controller that simply returns an image asset? I would like
I would like to create redirect response with POST parameters. For example controller returning
I would like to create a generic module/controller/action route in Zend Framework 2 to
I have created Controller Attribute and would like to read SessionId but get error
i would like create a array of structure which have a dynamic array :
I would like to create a c++ type that mimic the build-in type exactly.

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.