I just included T4MVC in my project and ran into an issue. I'm passing data to my javascript via hidden text fields and I need to be able to pass the names of controllers and their actions. Here's what I have:
<input type="hidden" id="logErrorUrl" name="logErrorUrl" value="@Url.Action("LogJavaScriptError", "Error") />
I'd like to be able to do:
<input type="hidden" id="logErrorUrl" name="logErrorUrl" value="@Url.Action(MVC.Error.LogJavaScriptError("")) />
For some reason this isn't working. I was thinking because LogJavascriptError doesn't return an ActionResult. FYI LogJavaScriptError also takes in a string but I really just want the name of the action. I also tried @MVC.Error.ActionNames.LogJavaScriptError but it doesn't show up perhaps again because it doesn't return an ActionResult?
T4MVC only works with action methods that return an ActionResult. If your method doesn't need to return anything, then the recommended thing to do is to return an EmptyResult, e.g.
public virtual ActionResult SomeAction() {
// Do stuff
return new EmptyResult();
}