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
Sujeet Raman
861
927
357.9k
How to call one controller from another controller in asp.net core api
Jan 19 2021 8:06 AM
Hi, this description may weired! but as a POC I want to do something like ..
I have an Employee controller .this controller is concidered as main controller and having a methode which fetch all the employee details based on their grade.Now i have to create 2 microservices for my project.Age and Gender is the 2 seperate MS.I want to know the correct way of creating/implimenting these microservices.
In Employee controller
[HttpPost(
"api/Employee/GetallEmployee"
)]
public
async Task GetallEmployee(input)
{
//i have to get merged json result here from below controllers(2 microservices having seperate db and seperate controller) and this url will connect with API gateway
// I should merge these 2 result( using newtonsoft i can do it)
//the merged json responce will concidered as main api
//is this the correct way to create microservices?
mergedresult= result1+result2
}
But in this i have some microservices like Age and Gender means for creating microservices in to my solution i have created seperate 2 controller like AgeController and GenderController
But the challenge i am facing is i have to call the main api only api/Employee/GetallEmployee
by using this i have to call both below controller and in main methode i shud combain the 2 joson results.Anyone please help me
AgeController
[HttpPost(
"api/Age/Ageofall"
)]
public
async Task Ageofall(input)
{
var result1 = await _getemployee.getalldetails(input);
return
new
JsonResult(result1);
}
GenderController
[HttpPost(
"api/Gender/Genderofall"
)]
public
async Task Genderofall(input)
{
var result2 = await _getemployee.getalldetails(input);
return
new
JsonResult(result2);
}
Please suggest the best practice to create microservices if i am doing wrong here..Thanks
Reply
Answers (
2
)
please help me for javascript code - ( countdown )
Asp.Net textbox TextChanged event is not firing