Click here to Skip to main content
14,766,867 members
Home » Discussions » ASP.NET
   

ASP.NET

 
GeneralRe: MVC RedirectToRouteResult Help Pin
Richard Deeming19-Oct-17 10:25
mveRichard Deeming19-Oct-17 10:25 
GeneralRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 11:58
professionalFoothill19-Oct-17 11:58 
GeneralRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 5:44
professionalFoothill19-Oct-17 5:44 
GeneralRe: MVC RedirectToRouteResult Help Pin
Richard Deeming19-Oct-17 10:18
mveRichard Deeming19-Oct-17 10:18 
PraiseRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 11:59
professionalFoothill19-Oct-17 11:59 
QuestionPassword Reset works in debug environment but does not work after deployment Pin
Philip Hall16-Oct-17 7:50
MemberPhilip Hall16-Oct-17 7:50 
AnswerRe: Password Reset works in debug environment but does not work after deployment Pin
A_Griffin18-Oct-17 22:49
MemberA_Griffin18-Oct-17 22:49 
GeneralRe: Password Reset works in debug environment but does not work after deployment Pin
Philip Hall19-Oct-17 6:10
MemberPhilip Hall19-Oct-17 6:10 
The token works fine and the user record is found. Those items are checked before the page is displayed that allows the user to enter a new password. It fails when it tries to submit the information. I do not have remote debugging capability so the best I can do is try to display error messages but none of them are displayed.

Code is included below:


@using Microsoft.AspNet.Identity;


@model CLCC_Browser.Models.ManageResetViewModel
@{
ViewBag.Title = "Password Reset";
Layout = "~/Views/Shared/_Layout.cshtml";
}

@ViewBag.Title.





@using (Html.BeginForm("ManageReset", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary()

@Html.HiddenFor(m => m.Token, new { @class = "form-control" })

@Html.HiddenFor(m => m.UserID, new { @class = "form-control" })


@Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })

@Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })



@Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" })

@Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" })



@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" })

@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" })







}

[AllowAnonymous]
public async Task<actionresult> ManageReset(string userName, string userId, string code)
{
IdentityResult result;
ManageResetViewModel model = new ManageResetViewModel();

var provider = new DpapiDataProtectionProvider("PokerResults");
UserManager.UserTokenProvider = new DataProtectorTokenProvider<applicationuser>(provider.Create("ResetPassword"));
UserManager.FindById(userId);
try
{
result = await UserManager.ConfirmEmailAsync(userId, testcode);
}
catch (InvalidOperationException ioe)
{
// ConfirmEmailAsync throws when the userId is not found.
ViewBag.errorMessage = ioe.Message;
return View("Error");
}

if (userId == null || code == null)
{
return View("Error");

}
ViewBag.HasLocalPassword = false;
ViewBag.UserID = userId;
model.UserName = userName;
model.UserID = userId;
model.Token = code;

return View(model);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<actionresult> ManageReset(ManageResetViewModel model)

{
IdentityResult result;

var provider = new DpapiDataProtectionProvider("PokerResults");
UserManager.UserTokenProvider = new DataProtectorTokenProvider<applicationuser>(provider.Create("ResetPassword"));
string thetoken = await UserManager.UserTokenProvider.GenerateAsync("ResetPassword", UserManager,
UserManager.FindByName(model.UserName));
model.Token = thetoken;

ModelState state = ModelState["NewPassword"];
if (state != null)
{
state.Errors.Clear();
}
if (ModelState.IsValid)
{
// result = await UserManager.AddPasswordAsync(User.Identity.GetUserId(), model.NewPassword);

result = await UserManager.ResetPasswordAsync(model.UserID, thetoken, model.NewPassword);
if (result.Succeeded)
{
ModelState.AddModelError("", "Password Reset Succeeded.");
Response.Write("alert('Password Updated');");
ViewBag.Message = "Password Reset Successful";
ViewBag.ResetType = "Complete";
Session["ResetStatus"] = "Complete";
return RedirectToAction("ResetPassword", "Account", "Complete");
// return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
}
else
{
ModelState.AddModelError("", "Password Update failed, User = " + model.UserID);
Response.Write("alert('Password Update failed');");
AddErrors(result);
}
}
else
{
ModelState.AddModelError("", "Password Update failed");
Response.Write("alert('Password Update failed - Invalid Model');");
}


return View(model);
}
Generalcode for solving zero distortion tecniqueof image steganography Pin
Member 1346535714-Oct-17 10:43
MemberMember 1346535714-Oct-17 10:43 
SuggestionRe: code for solving zero distortion tecniqueof image steganography Pin
Kornfeld Eliyahu Peter14-Oct-17 23:53
professionalKornfeld Eliyahu Peter14-Oct-17 23:53 
QuestionCode is inserting only one row of records. Any ideas? Pin
samflex9-Oct-17 6:16
Membersamflex9-Oct-17 6:16 
AnswerRe: Code is inserting only one row of records. Any ideas? Pin
F-ES Sitecore11-Oct-17 1:54
mveF-ES Sitecore11-Oct-17 1:54 
AnswerRe: Code is inserting only one row of records. Any ideas? Pin
ZurdoDev11-Oct-17 10:44
professionalZurdoDev11-Oct-17 10:44 
QuestionHave a form result invisible until submission? Pin
The Rarispy8-Oct-17 17:48
MemberThe Rarispy8-Oct-17 17:48 
AnswerRe: Have a form result invisible until submission? Pin
Richard Deeming9-Oct-17 9:42
mveRichard Deeming9-Oct-17 9:42 
QuestionChanging the text of a GridView buttonfield text dynamically Pin
holdorf7-Oct-17 16:10
Memberholdorf7-Oct-17 16:10 
QuestionASP.Net Core and global.asax Pin
Mou_kol6-Oct-17 0:21
MemberMou_kol6-Oct-17 0:21 
AnswerRe: ASP.Net Core and global.asax Pin
Afzaal Ahmad Zeeshan11-Oct-17 13:31
mveAfzaal Ahmad Zeeshan11-Oct-17 13:31 
QuestionDesktop application "communicating" with ASP.NET Pin
The Junior5-Oct-17 0:02
MemberThe Junior5-Oct-17 0:02 
AnswerRe: Desktop application "communicating" with ASP.NET Pin
Atlapure Ambrish5-Oct-17 5:04
professionalAtlapure Ambrish5-Oct-17 5:04 
GeneralRe: Desktop application "communicating" with ASP.NET Pin
The Junior5-Oct-17 5:24
MemberThe Junior5-Oct-17 5:24 
SuggestionRe: Desktop application "communicating" with ASP.NET Pin
Richard Deeming5-Oct-17 5:08
mveRichard Deeming5-Oct-17 5:08 
GeneralRe: Desktop application "communicating" with ASP.NET Pin
The Junior5-Oct-17 5:21
MemberThe Junior5-Oct-17 5:21 
GeneralRe: Desktop application "communicating" with ASP.NET Pin
David Mujica5-Oct-17 10:08
MemberDavid Mujica5-Oct-17 10:08 
GeneralRe: Desktop application "communicating" with ASP.NET Pin
The Junior5-Oct-17 22:34
MemberThe Junior5-Oct-17 22:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.