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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:07:59+00:00 2026-05-15T10:07:59+00:00

I have a problem similar to the one described here: MVC T4 MvcTextTemplateHost and

  • 0

I have a problem similar to the one described here: MVC T4 MvcTextTemplateHost and Customized "Controller" T4 Template but hopefully, simpler.

I have a custom View templates (View.tt, Create.tt) for ASP.NET MVC project. I can’t figure out how to get the controller name in these view templates. mvcHost.ControllerName and mvcHost.ControllerRootName both are null in View templates. However, somewhere in the pipeline controller name is known, since the view is created int the ControllerName folder. I want to refer to it in the template itself.

Specifically, I want to generate HTML.ActionLink("Edit", MVC.<controllername>.Edit(id)) instead of HTML.ActionLink("Edit", "Edit", new {id = item.id})

Is it possible to get the name of the controller in the View template?

  • 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-15T10:08:00+00:00Added an answer on May 15, 2026 at 10:08 am

    I don’t think there’s a way to get that info in MVC 1.0 or MVC 2. The ControllerRootName and ControllerName properties from the host are for controller T4 templates and not for view T4 templates.

    I’ll see if we can add more info to the T4 host to enable these properties when generating views.

    The reason that the generated file shows up in the right folder is that the MVC project system takes the output of the T4 template and puts it there. The T4 system itself doesn’t participate in this process.

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

Sidebar

Related Questions

I have similar problem to one discussed here , but with stronger practical usage.
I have a problem similar to the one described by LutherBaker here , i.e.
I have a problem very similar to the one described here: https://microsoft.public.win32.programmer.kernel.narkive.com/Ly2P8Yp2/prevent-vista-from-marking-my-application-as-non-responding That thread
I suppose similar problem would have been discussed here, but I couldn't find it.
I have a problem which seems very similar to the one described in http://markmail.org/message/6rlrzkgyx3pspmnf
I have encountered a similar problem described here (and in other places) - where
I have a problem similar to the one described in the link below. NSHTTPURLResponse
I have a very similar problem as described here . I also upgraded a
I'm trying to solve a problem similar to the one described here Initializing strongly
I have problem SIMILAR to preventing form data reposting, but not quite the same

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.