MVC Helper Extension issue

Posted by BeCool on Stack Overflow See other posts from Stack Overflow or by BeCool
Published on 2010-06-18T05:10:02Z Indexed on 2010/06/18 5:23 UTC
Read the original article Hit count: 160

Filed under:
|

Hi,

I need to implement a HtmlHelper extension in my MVC project simply just to output some string but ONLY in the DEBUG mode, not in REALEASE. My first attempt would be:


[Conditional("DEBUG")]
public static string TestStringForDebugOnly(this HtmlHelper helper, string testString)
{
return testString;
}

But obviously that would give a compile error: "The Conditional attribute is not valid because its return type is not void."

So my understanding is once you set [Condition] attribute, it doesnt allow to return anything? why? What is other way to implement this kind of function? anyone help would be much appreciated.

Thanks!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc