You are able to run code on NAS as long as this code doesn't actually call form functions. E.g., the following code is fine for NAS:
IF GUIALLOWED THEN
MyForm.SomeFunction();
But you will not be able to run function from a form even if it contains only non-GUI-specific logic. This is one of the reasons not to put any business logic on forms :)
The same rule goes to NAV Server and Web Services. Form (and dataport) objects are not being translated to C#, so it is not possible to run code from a form or dataport.