Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP MVC: Why aren't my internal classes visible from my Views?

Tags:

asp.net-mvc

<ul>
    <li><% Html.ActionLink(StringHelper.TryGetLocalString("Something"),
             "Blah", "Blah"); %></li>
</ul>

I had to make the StringHelper class above public before I could see it from within my partial view.

Why??

(side note: resolving to local string will be done in my controller not in the view (layout) but its a good quick example).

Thanks for you help, Luke

like image 593
Luke Puplett Avatar asked Aug 09 '10 19:08

Luke Puplett


1 Answers

Since the StringHelper is most likely not compiled into the same DLL as the rest of the code for the MVC site, it doesn't have access to internal things.

This will be the case when you have controllers, views, etc, as the default MVC website setup (and how it works when debugging) is to compile the regular code down to a DLL, then compile the pages/views separately. This also happens when you have "Updatability" setup when you publish the website.

like image 152
Rangoric Avatar answered Sep 28 '22 04:09

Rangoric