I'm trying to save data from WBF inputs to database through ASP.Net Web API following MVVM Pattern. I have checked the function it is also receiving data in proper format, checked by applying breakpoints. This is my Function in WPF:
private async void SubmitExecute ( object parameter )
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:60053/Api/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")
);
await client.PostAsJsonAsync("PostSignUp",User);
WindowsHelper.SignInPage();
}
I have tried applying breakpoint to my ASP.Net Post Function. It's not getting any hit from my WPF application. But I've checked it through my postman app, the ASP.net function works fine. Code of my ASP.net function:
[System.Web.Http.HttpPost]
public void PostSignUp([Bind(Exclude ="Id")]User user)
{
try
{
user.Id = Guid.NewGuid();
db.Users.Add(user);
db.SaveChanges();
}
catch (Exception ex)
{
ExceptionLogger.LogException(ex);
}
}