"Haven't I met you somewhere before?" the student asked.

Literal

"Previously [target-に] somewhere [at-で] met thing [subject-が] exists-not [polite-question-ませんか]" [quotative-と] that student [topic-は] asked.

~たことがある is the pattern for past experience ('have [ever] X-ed'), built from the past form + こと (thing/experience) + がある ('exists'). Negated as ありませんか ('don't you have the experience of...'), it's how you politely ask 'haven't you ever X-ed?' The whole dialogue attribution uses たずねた, the more literary form of 尋ねる.