"One issue that a few people have pointed out is that when a @helper is saved within the \app_code directory, you don’t by default get access to the ASP.NET MVC Html helper methods within it (e.g. Html.ActionLink(), Html.TextBox(), etc). You do get
access to the built-in HTML helper methods when they are defined in the same file as your views. This is not supported out of the box, though, when the helpers are within the \app_code directory - we’ll add this in the next release."
I have tested this in the MVC 4 beta release but this still does not work. Does onyone know if this will be solved in the final version of MVC4?
There is a good article which talks about re-using the helpers that are placed in a App_Code folder. If you want to specific subject, please search for "App_Code"
I have tested this in the MVC 4 beta release but this still does not work. Does onyone know if this will be solved in the final version of MVC4?
I have asked this specifically with Andrew Nurse about this. Here is it's response,
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Wim Pool
Member
1 Points
1 Post
Access to MVC Html helper methods in razor @helpers in App_Code folder
May 03, 2012 11:48 AM|LINK
In his blog post: http://weblogs.asp.net/scottgu/archive/2011/05/12/asp-net-mvc-3-and-the-helper-syntax-within-razor.aspx Scott states:
"One issue that a few people have pointed out is that when a @helper is saved within the \app_code directory, you don’t by default get access to the ASP.NET MVC Html helper methods within it (e.g. Html.ActionLink(), Html.TextBox(), etc). You do get access to the built-in HTML helper methods when they are defined in the same file as your views. This is not supported out of the box, though, when the helpers are within the \app_code directory - we’ll add this in the next release."
I have tested this in the MVC 4 beta release but this still does not work. Does onyone know if this will be solved in the final version of MVC4?
Thanx Wim
dwhite
Star
8990 Points
1423 Posts
Re: Access to MVC Html helper methods in razor @helpers in App_Code folder
May 14, 2012 11:04 PM|LINK
Not sure if this will be added, but there is a work-around
You can pass in a WebViewPage (which is your view itself) to the helper and use the Html helpers from there. For example:
@helper MyHelper(WebViewPage page) { page.Html.ActionLink("Home", "Index", "Home"); }Then in your view, it would just be:
Hope this helps,
-Damien
Latest Blog Post: BDD with ASP.NET MVC and Cucumber
abdu292
Participant
1553 Points
371 Posts
Re: Access to MVC Html helper methods in razor @helpers in App_Code folder
May 15, 2012 04:48 AM|LINK
There is a good article which talks about re-using the helpers that are placed in a App_Code folder. If you want to specific subject, please search for "App_Code"
http://www.pudd.co.uk/External-Blogs/10/Posts/2199
With best regards,
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Access to MVC Html helper methods in razor @helpers in App_Code folder
May 27, 2012 07:09 AM|LINK
I have asked this specifically with Andrew Nurse about this. Here is it's response,
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD