Base solution for your next web application

Activities of "hans abelshausen"

Yes, I have copied the code of your sample Project and the login page is shown, then I took username admin and your Password. In Accountcontroller loginResult is success but this code is never reached:

[AbpMvcAuthorize]
    public class HomeController : MyProjectControllerBase
    {
        public ActionResult Index()
        {
            return View("~/App/Main/views/layout/layout.cshtml"); 
        }
    }

It seems user is not logged in, but I don't know what is different in my Project... Here is the log file:

DEBUG 2015-06-08 11:16:56,063 [1 ] Abp.Localization.LocalizationManager - Initializing 4 localization sources. DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: Abp DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: AbpZero DEBUG 2015-06-08 11:16:56,067 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: AbpWeb DEBUG 2015-06-08 11:16:57,992 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: Test WARN 2015-06-08 11:16:58,315 [10 ] Default - Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) WARN 2015-06-08 11:17:15,594 [12 ] Default - Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext) Abp.Authorization.AbpAuthorizationException: No user logged in! bei Abp.Authorization.AuthorizeAttributeHelper.<AuthorizeAsync>d__0.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t) bei System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke() bei System.Threading.Tasks.Task.Execute() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter.GetResult() bei Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task) bei Nito.AsyncEx.AsyncContext.Run(Func1 action) bei Abp.Threading.AsyncHelper.RunSync(Func1 action) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IEnumerable1 authorizeAttributes) bei Abp.Authorization.AuthorizeAttributeHelper.Authorize(IAbpAuthorizeAttribute authorizeAttribute) bei Abp.Web.Mvc.Authorization.AbpMvcAuthorizeAttribute.AuthorizeCore(HttpContextBase httpContext)

I'm using Abp 0.6.2.0 Abp Zero 0.6.0.0

Yes, I have copied your code, here it is: (in my loginresult.User there is an error: internal error in method "Abp.Authorization.Users.AbpUserManager'3#AbpLoginResult[TTenant, TRole, TUser].get_user()")

using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using Abp.Authorization.Users;
using Abp.UI;
using Abp.Web.Mvc.Models;
using Microsoft.AspNet.Identity;
using Microsoft.Owin.Security;
using Test.Security.Users;
using Test.Web.Models.Account;


namespace Test.Web.Controllers
{
    public class AccountController : TestControllerBase
    {
        private readonly UserManager _userManager;

        private IAuthenticationManager AuthenticationManager
        {
            get
            {
                return HttpContext.GetOwinContext().Authentication;
            }
        }

        public AccountController(UserManager userManager)
        {
            _userManager = userManager;
        }

        public ActionResult Login(string returnUrl = "")
        {
            if (string.IsNullOrWhiteSpace(returnUrl))
            {
                returnUrl = Request.ApplicationPath;
            }

            ViewBag.ReturnUrl = returnUrl;

            return View();
        }

        [HttpPost]
        public async Task<JsonResult> Login(LoginViewModel loginModel, string returnUrl = "")
        {
            if (!ModelState.IsValid)
            {
                throw new UserFriendlyException("Your form is invalid!");
            }

            var loginResult = await _userManager.LoginAsync(
                loginModel.UsernameOrEmailAddress,
                loginModel.Password,
                loginModel.TenancyName
                );

            
            switch (loginResult.Result)
            {
                case AbpLoginResultType.Success:
                    break;
                case AbpLoginResultType.InvalidUserNameOrEmailAddress:
                case AbpLoginResultType.InvalidPassword:
                    throw new UserFriendlyException("Invalid user name or password!");
                case AbpLoginResultType.InvalidTenancyName:
                    throw new UserFriendlyException("No tenant with name: " + loginModel.TenancyName);
                case AbpLoginResultType.TenantIsNotActive:
                    throw new UserFriendlyException("Tenant is not active: " + loginModel.TenancyName);
                case AbpLoginResultType.UserIsNotActive:
                    throw new UserFriendlyException("User is not active: " + loginModel.UsernameOrEmailAddress);
                case AbpLoginResultType.UserEmailIsNotConfirmed:
                    throw new UserFriendlyException("Your email address is not confirmed!");
                default: //Can not fall to default for now. But other result types can be added in the future and we may forget to handle it
                    throw new UserFriendlyException("Unknown problem with login: " + loginResult.Result);
            }

            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
            AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = loginModel.RememberMe }, loginResult.Identity);

            if (string.IsNullOrWhiteSpace(returnUrl))
            {
                returnUrl = Request.ApplicationPath;
            }
            
            return Json(new MvcAjaxResponse 
            { 
                TargetUrl = returnUrl
            });
            //return Json(new MvcAjaxResponse 
            //{ 
            //    TargetUrl = returnUrl
            //    //TargetUrl = "/#/"
            //});
        }

        public ActionResult Logout()
        {
            AuthenticationManager.SignOut();
            return RedirectToAction("Login");
        }
    }
}

I have updated to newest version of Abp.Zero and if I check the loginAsync function, there is a difference between my solution and yours. the castle.proxies.usermanagerproxy base AbpSession is Abp.TestBase.Runtime.Session.TestAbpSession in your code it is Abp.Runtime.Session.AbpSession Is this perhaps the problem? Where can I change it?

I can't find the test package. I have added the Abp.Zero version 0.6.3.4 Strange...

This is also an error of my login: Failed to load resource: the server responded with a status of 500 (Internal Server Error) Perhaps it is the same problem described here: [http://forum.aspnetboilerplate.com/viewtopic.php?f=3&t=214])

No, I haven't a test package included. Only Abp.Zero version 6.0.3.4 but Abp.TestBase.Runtime.Session.TestAbpSession as Session. Is the TestAbpSession included in the abp.zero package?

I only installed Abp.Zero and Abp.Zero.EntityFramework, but in accountcontroller _userManager.AbpSession is Abp.TestBase.Runtime.Session.TestAbpSession What I'm doing wrong?

Here is the wrong Session:

public UserStore(
            IRepository<User, long> userRepository,
            IRepository<UserLogin, long> userLoginRepository,
            IRepository<UserRole, long> userRoleRepository,
            IRepository<Role> roleRepository,
            IRepository<UserPermissionSetting, long> userPermissionSettingRepository,
            IAbpSession session,
            IUnitOfWorkManager unitOfWorkManager)
            : base(
                userRepository,
                userLoginRepository,
                userRoleRepository,
                roleRepository,
                userPermissionSettingRepository,
                session,
                unitOfWorkManager)
        {
        }

Hi, I have downloaded a brand new project from your site and added my classes. Now Login works perfectly, abp.session is now the right one and not the testbase.session. But I did not found my error. I uninstalled every abp project and reinstalled abp. But still error is shown. So I decided to make a new project! Thanks a lot.

Sorry for my short question. I'm trying to unterstand the error. The error occurs in my debug mode too, but somewhere else. In my console the following error appears (I have intgegrated module Zero. Something with getting users seems to be the error): exceptionMessage: "The 'ObjectContent1' type failed to serialize the response body for content type 'application/json; charset=utf-8'." exceptionType: "System.InvalidOperationException" innerException: Object exceptionMessage: "Error getting value from 'CreatorUser' on 'System.Data.Entity.DynamicProxies.User_4730030EBB16241189B87A85A8706EE27908E7C722E1DAFA1C3B46C6AEC5217E'." exceptionType: "Newtonsoft.Json.JsonSerializationException" innerException: Object exceptionMessage: "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection." exceptionType: "System.ObjectDisposedException" message: "An error has occurred." stackTrace: " bei System.Data.Entity.Core.Objects.ObjectContext.get_Connection() ↵ bei System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) ↵ bei System.Data.Entity.Core.Objects.ObjectQuery1.Execute(MergeOption mergeOption) ↵ bei System.Data.Entity.Core.Objects.DataClasses.EntityReference1.Load(MergeOption mergeOption) ↵ bei System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.Load() ↵ bei System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.DeferredLoad() ↵ bei System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.LoadProperty[TItem](TItem propertyValue, String relationshipName, String targetRoleName, Boolean mustBeNull, Object wrapperObject) ↵ bei System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.<>c__DisplayClass72.<GetInterceptorDelegate>b__2(TProxy proxy, TItem item) ↵ bei System.Data.Entity.DynamicProxies.User_4730030EBB16241189B87A85A8706EE27908E7C722E1DAFA1C3B46C6AEC5217E.get_CreatorUser() ↵ bei GetCreatorUser(Object ) ↵ bei Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)" proto: Object message: "An error has occurred."

Showing 1 to 10 of 17 entries