Maxperson
Morkus from Orkus
Answer 3: Don't trust the necromancer and use other means to verify if he has the information or not.So the necromancer doesn't have one obvious answer, it has two. Give the artifact or don't give the artifact. Two completely logical answers to this problem, both of which are valid and obvious and the players just have to choose one of them. And I am willing to bet that whoever the DM was (you or whomever) knew what the necromancer would do with the artifact if it was given, or do to the party if they did not. So your scenario is railroading the party just as much as any other scenario.
Answer 4: Gather allies to capture the necromancer and force him to talk.
Answer 5: Give a fake artifact and and try to get the info out of the necromancer before he discovers that he was duped.
Answers: 6+ other ideas.
This idea you have that there is an obvious correct answer or two is flawed. There are many "smart"/"good play" answers to virtually all dilemmas.
You don't have nearly enough information to say this with any sort of confidence. We don't know why they are there or what else they could have tried other than escape. Depending on the specific circumstances, though, there are many possibilities.And the prison? Getting out and escaping WAS the obvious solution to the problem was it not? So you've railroaded the players there too, by putting them in a situation where there's only one logical result-- escaping the prison. Sure the methodology for how to accomplish it could have various answers, but the solution to their problem was railroaded by you from the get-go.