TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Deepika Chaudhary
1.6k
136
97.8k
Using web api how to work with controller
Jun 22 2019 12:12 AM
I am using following code. let me know any other way
public
async Task<ActionResult> Index()
{
string
userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
string
qName = userName.Replace(
"AMAT\\", "
");
string
apiUrl =
"http://dca-dev-577/deepika.ldap/api/AD/seachADUsers?searchText="
+qName;
using
(HttpClient client =
new
HttpClient())
{
client.BaseAddress =
new
Uri(apiUrl);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new
System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(
"application/json"
));
HttpResponseMessage response = await client.GetAsync(apiUrl);
if
(response.IsSuccessStatusCode)
{
var data = await response.Content.ReadAsStringAsync();
var table = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Data.DataTable>(data);
JArray rss = JArray.Parse(data);
//JObject rss = JObject.Parse(data);
string
FName = rss[0][
"FirstName"
].ToString();
string
LName = rss[0][
"LastName"
].ToString();
ViewBag.message =
"First Name: "
+ FName +
" Last Name: "
+ LName;
}
}
return
View();
}
Reply
Answers (
2
)
Need code to call webservice which will transfer CSV data
HTTPPUT vs HTTPPOST