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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:46:10+00:00 2026-05-14T22:46:10+00:00

Ok, maybe the title isn’t the most descriptive thing in the world, but this

  • 0

Ok, maybe the title isn’t the most descriptive thing in the world, but this problem is killing me. What I’m trying to do is create an ActionLinkFor helper method, like so:

public ActionResult Index()
{
   // Does Stuff
}

public ActionResult SomeAction(int param1)
{
   // Does Stuff
}

These are two action methods. Action methods can have any number of parameters, but for the purposes of my expression, I don’t care. Ideally, what I have been trying for is something like this:

<%= Html.ActionLinkFor<HomeController>(m => m.Index, "Return Home") %>

which would return

<a href="/Home/Index">Return Home</a>

based on the expression it parsed. The objective being that now I’m not using ‘magic strings’ for determining the links, but instead a compiled lambda expression. If anything was refactored, or a page was changed location, it would be clear what links had been pointing where.

The problem is, the lambda expression for that method handle doesn’t seem to resolve to the right overload. I figured I would have to make a few overloads like so:

public static MvcHtmlString ActionLinkFor<Controller>(this HtmlHelper helper, Expression<Func<Controller, ActionResult>> methodExpression, string linkName)
{
     // return parsed expression translated into a link
}

public static MvcHtmlString ActionLinkFor<Controller>(this HtmlHelper helper, Expression<Func<Controller, object, ActionResult>> methodExpression, string linkName)
{
    // Does the same thing
}

That way, when I said

m => m.Index // Chooses first ActionLinkFor since the Lambda would be a Func<Controller, object>
m => m.SomeAction // Chooses second ActionLinkFor since the method signature is different.

However, this doesn’t seem to be working. If I specify multiple generic parameters like so:

<%= Html.ActionLinkFor<HomeController, int>(m => m.SomeAction, "Some Link") %>

it picks it up just fine, but I don’t want to have to specify the method signature in the generic argument list. So my questions are:

1) Is there a way to ‘target’ a method name regardless of it’s signature? I can use reflection to get all the methods and use a magic string, but I want there to be a lambda expression at design time so I can specify the link then.

2) If you can provide a solution, is there a simple way of parsing out the method name? The algorithm I’m currently using is more than likely a bad idea, and effectively involves a few conversions and then eventually parsing a string when I couldn’t get it to a more convenient type.

  • 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-14T22:46:10+00:00Added an answer on May 14, 2026 at 10:46 pm

    It looks like I’m reinventing the wheel. I’ll take a look at the MVC Futures code.

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

Sidebar

Related Questions

Maybe isn't good title for the question but my problem is exactly this. I
Title sums it up. URL isn't an EKEvent property but figured maybe there's some
Maybe the title is a little missleading but I'd like to ask you for
Maybe my title is not the best but here is what I really want.I
Maybe the title is not so descriptive. I'm working right with Galasoft MVVM framework,
Maybe the title could be rephrased slightly better but basically I'm wondering how the
I'm not too great with jquery and maybe this title doesn't explain too well
NEW INFO: Something I just noticed (because this isn't something I'd normally do), but
I know this subjet isn't new at all but i'm going to be crazy
Maybe the title is a little bit obscure, but let me explain... In a

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.