Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Object array in Wep Api

$
0
0

Hi folks,

In Console App:

Staic Void(.....){

// rest omitted

 while (ienum.MoveNext())
 {
    LdapAttribute attribute = (LdapAttribute)ienum.Current;
    string attributeName = attribute.Name;
    string attributeVal = attribute.StringValue;

    if (attributeName == "displayName" || attributeName == "mail")
    {
        Console.WriteLine(attributeName + ": " + attributeVal);
    }
 }

// rest omitted

}

Output:
mail: abc@email.com
displayName: abc
mail: xyz@email.com
display: xyz
.
.
.

It seems good. But i want to display output like object array in Web api.

[
 {"mail": "abc@email.com","displayName": "abc"
 },

 {
  "mail": "xyz@email.com","display": "xyz"
 }
.
.
.
]


In Wep Api:

[HttpGet("UserInfo")]
public IActionResult Get()
{
	// rest omitted
	while (ienum.MoveNext())
	{
		LdapAttribute attribute = (LdapAttribute)ienum.Current;
		string attributeName = attribute.Name;
		string attributeVal = attribute.StringValue;

		if (attributeName == "displayName" || attributeName == "mail")
		{//Console.WriteLine(attributeName + ": " + attributeVal);
			??
		}
	}
	// rest omitted
}

I am waiting for your response.

Thanks in Advance




Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>