views:

39

answers:

2

This may be a duplicate of some other question, but it's hard to search the web for <%: so I can't really find anything.

When I created a new Asp.net MVC 2 project its templates use the new notation of automatic html encoding. WHen I changed .net framework target to 3.5, these server scripts stopped working. When I changed them to <%= everything was fine, but it's not the same.

Anyway. Is it possible to take advantage of this notation and avoid writing tedious and long statements <%= Html.Encode(...) %>?

+1  A: 

As far as I know, this is an ASP.NET 4.0 only feature - so on 3.5, you still need to remember to use the Html.Encode(.....)..... another good reason to upgrade! :-)

marc_s
Well sometimes you can't upgrade because it depends on another product, that's built in 3.5... :(
Robert Koritnik
Can't you set up assembly binding redirects for those?
Rup
+3  A: 

Unfortunately it is not possible. It is mentioned in the following article. See the section titled Helpers now return an MvcHtmlString object. Also, see the explanation from Phil Haack as to why.

Garett