Click here to Skip to main content
15,924,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
afternoon i need held i want to restrict a user being able to enter a url like
Account/ResetPassword and get redirected to that page even if they are logged out.
i was told to use a query string with parameters but from my research im hiiting a brick wall.

here is my forgot controller,that i want to restrict i added a authorize attribute only.but i want to use query string

C#
[HttpPost]
[AllowAnonymous]
[Authorize(Roles = "Admin")]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model)
{
    if (!ModelState.IsValid)
    {
        return View(model);
    }
    RegisterBusiness reg = new RegisterBusiness();
    ApplicationUser user = new ApplicationUser();
    user = reg.UserManager.FindByEmail(model.Email);
    if (user == null)
    {
        ModelState.AddModelError("", "No user found.");
        return View();
    }
    IdentityResult result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
    if (result.Succeeded)
    {
        return RedirectToAction("ResetPasswordConfirmation", "Account");
    }
    AddErrors(result);
    return View();
}


[edit]SHOUTING removed - OriginalGriff[/edit]
Posted
Updated 11-Sep-15 0:08am
v2
Comments
OriginalGriff 11-Sep-15 6:09am    
1) DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
2) This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
F-ES Sitecore 11-Sep-15 6:14am    
The authorise attribute is the right way of doing this, I don't know what you mean by "use the query string". You can't stop a user entering anything they want into the address bar.
There is a comment for you. :)
Member 11488938 11-Sep-15 6:36am    
apologies for the caps.@F-ES Sitecore is there a better way then using authorize attribute to restrict the access to certain views.
Reply to the comment. Don't add another comment, he won't be notified.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900