thank you for contacting the wefugees community.
Basically the Ausländerbehörde is right when asking you to go to your homecountry and apply for the correct visa. The law says they CAN refrain from this if you a) have a right (Anspruch) to get the residence permission and b) it is not reasonable to go back for the visa application. "B)" depends on the individual case. I recommend you turn to a local refugee advisor who can take a closer look at your case.
I hope I could answer your question!