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
Jayraj Goswami
NA
198
12.4k
Different Method not call webapi Project to MVC Project
Feb 17 2016 1:56 AM
This is My Webapi Controller Method
static readonly IRegCls RegObj = new SampleApplicationWebApi.Models.MyTest.RegCls();
public HttpResponseMessage GetFirstName(RegistrationMst ObjReg)
{
RegistrationMst Users = RegObj.GetFirstName(ObjReg);
if (Users == null)
{
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "S O R R Y");
}
else
{
return Request.CreateResponse<RegistrationMst>(HttpStatusCode.OK, Users);
}
}
public HttpResponseMessage GetLastName(RegistrationMst ObjReg)
{
RegistrationMst Users = RegObj.GetLastName(ObjReg);
if (Users == null)
{
return Request.CreateErrorResponse(HttpStatusCode.NotFound, "S O R R Y");
}
else
{
return Request.CreateResponse<RegistrationMst>(HttpStatusCode.OK, Users);
}
}
How to call different Method in my MVC Project
My Calling
This MVC Controller
[HttpPost]
public ActionResult GetFirstName(RegistrationMst RejObj)
{
var client = new HttpClient();
var response = client.PostAsJsonAsync("http://localhost:43536/api/RegAPI", RejObj).Result;
if (response.IsSuccessStatusCode)
{
}
return RedirectToAction("Index", "Home");
}
[HttpPost]
public ActionResult GetLastName(RegistrationMst RejObj)
{
var client = new HttpClient();
var response = client.PostAsJsonAsync("http://localhost:43536/api/RegAPI/GetLastName", RejObj).Result;
if (response.IsSuccessStatusCode)
{
}
return RedirectToAction("Index", "Home");
}
Current Issue is Method Not Fount
<input type="submit" value="Test11" class="btn btn-def btn-block button" formaction="/MyTest/GetLastName" />
Reply
Answers (
1
)
Partial Postbacks WITHOUT UPDATE PANEL
Web Api Smple With DTO API MVC