Disclosed are pyrrolo[2,1-f][1,2,4]triazine compounds of formula I wherein ring B is a 5, 6, 7 or 8 membered heterocyclic ring comprising one or more double bonds, and is substituted with one or more oxo, thioxo or SO2R' group, salts thereof and methods for the compounds' preparation. The compounds of formula I are useful for treating cancer and viral infections such as hepatitis B, hepatitis C (HCV), human immunodeficiency virus (HIV), Polio, Coxsackie A and B, Rhino, Echo, small pox, Ebola, and West Nile virus.