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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:56:13+00:00 2026-06-06T00:56:13+00:00

I am trying to create an extension method. But I get: No Overload for

  • 0

I am trying to create an extension method. But I get:

No Overload for method MRUrl takes 0 arguments

HtmlHelper.cs:

namespace MyNS.Helpers
{
   public class MyHelper
   {
    public static string MRUrl(this UrlHelper url)
    {
         return "blah"
    }
  }
}

View:

@MyNS.Helpers.MyHelper.MRUrl()
  • 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-06T00:56:14+00:00Added an answer on June 6, 2026 at 12:56 am

    You are not calling the extension method correctly. It should be:

    @Url.MRUrl()
    

    Please read about how extension methods work in C# before using them: http://msdn.microsoft.com/en-us/library/bb383977.aspx

    An extension method extends a given type (UrlHelper in your case) and is invoked on an instance of this type. So since inside your view you already have an instance of UrlHelper (throughout the Url property) and so you can directly invoke your extension method on it.

    Before being able to invoke an extension method you need to bring it into scope by adding the namespace in which its containing class is defined:

    @using MyNS.Helpers
    @Url.MRUrl()
    

    Also extension methods must be declared inside a static class. Your C# code won’t even compile. So fix it:

    namespace MyNS.Helpers
    {
        public static class HtmlHelper // Bad name choice I know.
        {
            public static string MRUrl(this UrlHelper url)
            {
                return "blah";
            }
        }
    }
    

    All that’s standard C#, nothing to do with ASP.NET MVC or Razor.

    Now something ASP.NET MVC specific: if you want to avoid the need of having to bring the namespace into scope into each view (@using MyNS.Helpers) you could add it to the <namespaces> tag of your ~/Views/web.config file (not to be confused with the ~/web.config).

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

Sidebar

Related Questions

I am trying to create an extension method for the generic delegate Action<T> to
I'm trying to create an extension method using CodeDOM. There doesn't seem to be
I am trying to create an overloaded Add method as an extension to the
I am trying to create an extension method that i can forward a IList
I'm trying to create a generic extension method, that works on typed data tables
I'm trying to use the Html.DropDownList extension method but can't figure out how to
I am trying to create chrome extension which will read text inside the particular
I was trying to create an extension that could slice any array-like class (since
I'm trying to create a bookmark extension in Chrome and I want to leverage
I am trying to create Google Chrome extension that will send interesting links to

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.