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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:11:23+00:00 2026-06-12T15:11:23+00:00

As the title states. I have an MVC 3 Razor view which i would

  • 0

As the title states. I have an MVC 3 Razor view which i would like to programmatically instantiate and obtain a list of it’s Html helpers.

anyone have any good suggestions on how to approach this?

Thanks in advance

  • 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-12T15:11:25+00:00Added an answer on June 12, 2026 at 3:11 pm

    I was able to achieve this by executing a custom view result and updating the model from my html helper.

    Action Method:

        public ActionResult GetListViewHelpers()
        {
            var model = new TestModel(); // has >>> public List<MyHelper> Helpers { get; set; }
    
            var testContext = new ControllerContext();
            testContext.Controller = new MyController();
            testContext.HttpContext = HttpContext;            
            testContext.RouteData.Values["controller"] = "MyController";
            testContext.RouteData.Values["action"] = "Index";
    
            var view = new TestViewResult();
            view.ViewData.Model = model;
            view.ViewName = "TestView";  // i want a list of the helpers from this view          
            view.ExecuteResult(testContext);
    
            return View(model); // model.Helpers contains a list of helpers within a required view
        }
    

    View Result:

    public class TestViewResult : ViewResult 
    {
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)            
                throw new ArgumentNullException("context");
    
            if (String.IsNullOrEmpty(ViewName))            
                ViewName = context.RouteData.GetRequiredString("action");
    
            ViewEngineResult result = null;
    
            if (View == null)
            {
                result = FindView(context);
                View = result.View;
            }
    
            var stream = new MemoryStream();
            var writer = new StreamWriter(stream);
            ViewContext viewContext = new ViewContext(context, View, ViewData, TempData, writer);
    
            using (stream)
            using (writer)
            {
                View.Render(viewContext, writer);
                writer.Flush();
            }
    
            if (result != null)            
                result.ViewEngine.ReleaseView(context, View);            
        }
    }
    

    Helper:

        public static MvcHtmlString AHelper(this HtmlHelper helper, string name)
        {
            var model = (TestModel)helper.ViewData.Model;
    
            if(model.Helpers == null)
                model.Helpers = new List<MyHelper>();
    
            model.Helpers.Add(new MyHelper()
            {
                Name = name // add all the info i want from the helpers overloads
            });
    
            // .... helper logic here
    
            return null;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As the title states I would like to know how to list all rpms
As the title states, I'd like my MVC sites to have an URL pattern
As the title states, I have a C# console app which uses interop to
Like the title states, does anyone out there have a clear way to implement
I have an ASP.NET MVC 3.0 partial view which is render inside a jquery
I have a Html.Telerik().Grid() that is bound to a model in my MVC view.
I have a simple view: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage %> <asp:Content ID=Content1
as the title states: I have a select query, which I'm trying to order
I have a weird need in an ASP.NET MVC 3 application which blocks my
Exactly like my title states i need a query that removes the first chracter

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.