0

I'm developing an API in ASP.Net Core for a school assignment and I need to return schema's with my XML responses.

Now, I have my own schema files made for this project (requirement of the assignment, generating these is not an option). I want to add a schemaLocation attribute to my XML response.

Currently I'm trying to add an extra field to my class that defines the attribute, but it doesn't show up in the XML attributes. The field I added to my class looks like this:

[XmlAttribute("schemaLocation")]
[NotMapped]
public string schema { get; private set; } = "/schemas/xml/schemafile.xml";

What am I doing wrong?

Thank you in advance.

Naamloos
  • 39
  • 5
  • 1
    `private set` is the problem. https://stackoverflow.com/questions/13401192/why-are-properties-without-a-setter-not-serialized – Oguz Ozgul Apr 03 '20 at 16:35
  • Thank you! It's amazing how long one can spend looking when the answer is so simple.. @OguzOzgul – Naamloos Apr 03 '20 at 16:40

0 Answers0