Are we supposed to be able to follow a AJAX call in the debugger to see what's going on? Because for some reason it seems like the call isn't going to where it's supposed to go to.
When stepping through the program, after the url: '@URL.Action("DidItWork", "Home")
call, it goes to:
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
Followed by several other methods; however, it doesn't appear that it hits any of the lines of code in the DidItWork() action method (based on breakpoints).
I then get Error: Not Found. Status: error. Console: [object Object]
Thoughts/suggestions on how to resolve this issue of the @Url.Action call not setting off any break points in the DidItWork() action method? Because the @Url.Action call isn't getting to the desire effect of having reaching SendEmailAsync().
The following code is in _Layout.cshtml
@*script for someone who presses the send/email button*@
<script>
$("#sendButton").click(function () {
alert("Send button pressed");
$.ajax({
url: '@Url.Action("DitItWork", "Home")',
success: function (result) {
alert("Success. It worked: " + result);
},
error: function( xhr, status, errorThrown ) {
alert("Sorry, there was a problem! Error: " + errorThrown + ". Status: " + status + ". Console: " + xhr);
console.log("Hello");
console.log("Error: " + errorThrown);
console.log("Status: " + status);
console.dir(xhr);
console.log("Good-bye");
},
});
return false;
});
</script>
The following code is in HomeController.cs
[AllowAnonymous]
public async Task<ActionResult> DidItWork()
{
var dash = "dash equals nash";
var manager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
var user = new ApplicationUser { UserName = "test2 username2", Email = "testemail2@gmail.com" };
var result = await manager.CreateAsync(user, "passwordGoesHere1!");
if (result.Succeeded)
{
await manager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account");
return View();
}
//AddErrors(result);
return View();
}
Your Action name is DidItWork, but you are sending request to DitItWork. But for the feature install some tool or use already existing in you web browser to check where request is sending(for example I am using firebug in firefox).