Answered step by step
Verified Expert Solution
Question
1 Approved Answer
help me to solve this issue: Severity Code Project File Description Line Suppression State Error CS 0 8 1 5 Library Management System ( LMS
help me to solve this issue:
Severity Code Project File Description Line Suppression State
Error CS Library Management SystemLMS C:UsersbksghSourceReposbbksAssignmentLibrary Management SystemControllersAccountControllercs Cannot assign void to an implicitlytyped variable NA
my full code:
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin.Security;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using LibraryManagementSystem.Models;
namespace LibraryManagementSystem.Controllers
Authorize
public class AccountController : Controller
private ApplicationSignInManager signInManager;
private ApplicationUserManager userManager;
public AccountController
public AccountControllerApplicationUserManager userManager, ApplicationSignInManager signInManager
UserManager userManager;
SignInManager signInManager;
public ApplicationSignInManager SignInManager
get return signInManager HttpContext.GetOwinContextGet;
private set signInManager value;
public ApplicationUserManager UserManager
get return userManager HttpContext.GetOwinContextGetUserManager;
private set userManager value;
GET: AccountLogin
AllowAnonymous
public ActionResult Loginstring returnUrl
ViewBag.ReturnUrl returnUrl;
return View;
POST: AccountLogin
HttpPost
AllowAnonymous
ValidateAntiForgeryToken
public async Task LoginLoginViewModel model, string returnUrl
if ModelState.IsValid
return Viewmodel;
var result await SignInManager.PasswordSignInAsyncmodelEmail, model.Password, model.RememberMe, shouldLockout: false;
switch result
case SignInStatus.Success:
return RedirectToLocalreturnUrl;
case SignInStatus.LockedOut:
return ViewLockout;
case SignInStatus.RequiresVerification:
return RedirectToActionSendCode new ReturnUrl returnUrl, RememberMe model.RememberMe ;
case SignInStatus.Failure:
default:
ModelState.AddModelError "Invalid login attempt.";
return Viewmodel;
GET: AccountRegister
AllowAnonymous
public ActionResult Register
return View;
POST: AccountRegister
HttpPost
AllowAnonymous
ValidateAntiForgeryToken
public async Task RegisterRegisterViewModel model
if ModelStateIsValid
var user new ApplicationUser UserName model.Email, Email model.Email ;
var createUserResult await UserManager.CreateAsyncuser model.Password;
if createUserResultSucceeded
await SignInManager.SignInAsyncuser isPersistent: false, rememberBrowser: false;
return RedirectToActionIndex "Home";
AddErrorscreateUserResult;
If we got this far, something failed, redisplay the form
return Viewmodel;
POST: AccountLogOff
HttpPost
ValidateAntiForgeryToken
public ActionResult LogOff
AuthenticationManager.SignOutDefaultAuthenticationTypesApplicationCookie;
return RedirectToActionIndex "Home";
Rest of your AccountController actions
private ActionResult RedirectToLocalstring returnUrl
if UrlIsLocalUrlreturnUrl
return RedirectreturnUrl;
else
return RedirectToActionIndex "Home";
private void AddErrorsIdentityResult result
foreach var error in result.Errors
ModelState.AddModelError error;
private IAuthenticationManager AuthenticationManager
get
return HttpContext.GetOwinContextAuthentication;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started