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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:17:29+00:00 2026-06-01T17:17:29+00:00

I have ASP.NET MVC3 project and I am writing some extension methods that returns

  • 0

I have ASP.NET MVC3 project and I am writing some extension methods that returns HTML but I need UrlHelper for rendering them. To do that I am extending UrlHelper but I don’t like the semantics because UrlHelper should work with URLs and HtmlHelper with HTML. I’d like to extend HtmlHelper with this methods instead of UrlHelper.

My problem is that I don’t now how to access UrlHelper from extension method of HtmlHelper, is it even possible? Or I have to stick with UrlHelper extensions.

I know that I can send Url helper as an argument but I don’t like this solution very much.

Following code is sample of extension method I am talking about:

public static HtmlString AnchorLink(this UrlHelper url, string text, string action, string anchor) {
    return new HtmlString(string.Format("<a href=\"{0}#{2}\">{1}</a>", url.Action(action), text, anchor));
}

Thanks

  • 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-01T17:17:31+00:00Added an answer on June 1, 2026 at 5:17 pm

    You could instantiate an UrlHelper yourself…

    public static HtmlString AnchorLink(this HtmlHelper html, string text, string action, string anchor) {
        var urlHelper = new UrlHelper(html.ViewContext.RequestContext);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some C# code in my ASP.NET MVC3 project that's throwing an exception
I'm writing a project in c# asp.net mvc3, and I have a helper-class that
I'm creating a project from the book Sanderson Pro ASp.net mvc3. But I have
I have an asp.net mvc3 project, it has some reports in aspx web pages.
I have an ASP.NET MVC3 project that uses a tab strip on certain pages.
I have an ASP.NET MVC3 project. I want to insert some <td> 's in
I have an ASP.Net MVC3 project that calls a WCF service to get data.
I have MVC3 asp.net project. I create controller function with some parameters, the question
In an ASP.NET MVC3 project I have a structure like this: Core.csproj -> 3rdparty1.dll
i have a problem with the asp.net MVC3. when i create a new project

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.