Made razor compilation more robust

- Support other kinds of references when compiling razor views
- Cache application references since they can't change throughout the lifetime
of the running application

/cc @pranavkm