2

Simple question: I need to return an array from a helper function:

@helper arrayBuilder(){
      string pages = System.Configuration.ConfigurationManager.AppSettings["siteNav"];
      pages = pages.Replace(" ", string.Empty);
      string[] pagesTable = pages.Split(',');

   return pagesTable;
}

Why on earth isnt this possible?

2 Answers 2

1

This method shouldn't be a helper function. This should be in your controller and returned in your model. Helper functions are there for display only. A clue to this is because you are calling System.Configuration.ConfigurationManager.AppSettings.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, yes I suspected i was adding code in the wrong place.
1

Perhaps using @function syntax would help here?

@helper returns an item to render, e.g. some HTML, but I think that @function should allow you return a value

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.