Base solution for your next web application

Activities of "xmarwin"

Hello. For our project we need import old data from MySQL database, so I have created new console application and added it among the projects. I have entered the AspZeroLicenseCode to my appsettings.json. Unfortunately I'm unable to start it, because it complains incorrect project name:

Failed to validate project name. Should not rename a project downloaded from aspnetzero.com.

Here is my solution structure:

What exactly are the rules that are being checked (regarding the project name)?

Thanks, Martin

Hello. Thanks for quick reply. At the end it turned out that my appsettings.json file was configured not to copy to Debug folder, so the AbpZeroLicenseCode was always null. Thanks, Martin

Question

Hello. I am trying to create custom session using this article (and several others) but it seems to be already obsolete. I need to create custom session with one (for the sake of simplicity) enum called AdelRoles that is changed on users login action. I have added following code:

Session Class:

public class AdelSession : ClaimsAbpSession, ITransientDependency
{
    public AdelSession(
        IPrincipalAccessor principalAccessor,
        IMultiTenancyConfig multiTenancy,
        ITenantResolver tenantResolver,
        IAmbientScopeProvider<SessionOverride> sessionOverrideScopeProvider) :
        base(principalAccessor, multiTenancy, tenantResolver, sessionOverrideScopeProvider)
    {}

    public AdelRoles AdelRoles
    {
        get
        {
            var adelRoles = PrincipalAccessor.Principal?.Claims.FirstOrDefault(c => c.Type == "AdelRoles");
               
            if (string.IsNullOrEmpty(adelRoles?.Value))
            {
                return AdelRoles.None;
            }

            return (AdelRoles)int.Parse(adelRoles.Value);
        }
    }
}

TokenAuthController:

  • added following method:
private void UpdateAuthorizationGroup(User user, ClaimsIdentity identity)
{
    var adelRoles = AdelRoles.Supporter;            
    identity.AddClaims(new List<Claim>() { new Claim("AdelRoles", ((int)adelRoles).ToString()) });
}

that is called at the end of Task<AuthenticateResultModel> Authenticate([FromBody] AuthenticateModel model) method:

.....
//Login!
UpdateAuthorizationGroup(loginResult.User, loginResult.Identity);
var accessToken = CreateAccessToken(CreateJwtClaims(loginResult.Identity));

return new AuthenticateResultModel
{
    AccessToken = accessToken,
    EncryptedAccessToken = GetEncrpyedAccessToken(accessToken),
    ExpireInSeconds = (int)_configuration.Expiration.TotalSeconds,
    TwoFactorRememberClientToken = twoFactorRememberClientToken,
    UserId = loginResult.User.Id,
    ReturnUrl = returnUrl
};

Then later I read from my AdelSession.AdelRoles but unfortunately I always get AdelRoles.None as AdelRoles is not among the claims.

What am I doing wrong?

Thanks for any hint. Best regards, Martin.

Answer

Hi maliming. Thanks for the quick reply. I am not sure what happened but things that didn't work yesterday work today... I restarted my notebook, maybe that may have solved the issue? It's a bit embarrassing as I spend entire day yesterday trying to make this work. Anyway, consider it fixed.

Best regards, Martin.

Hello. Is there any way how I can update the "Current user did not login to the application" error message from ABP? I couldn't find this option anywhere in the code. Thanks.

Best regards, Martin

Hello ismcagdas. I followed mentioned document but unfortunately I was not able to make it work.

This is - I guess - the essential part: Configuration.Localization.Sources.Extensions.Add( new LocalizationSourceExtensionInfo("AbpWeb", new XmlEmbeddedFileLocalizationDictionaryProvider( Assembly.GetExecutingAssembly(), "MyCompany.MyProject.Localization.Sources" ) ) );

  • I want to override this error message: "You have been logged out. Click ok to log in again". I can find it in the Abp.dll so I assume the AbpWeb should be replaced by Abp
  • I store the new translation in the same file as any other translations, so I replaced "MyCompany.MyProject.Localization.Sources" by "Adel.Portal.Localization.Portal"
  • Since this exception is raised by the Application module I put this code into the PortalApplicationModule PreInitialize method

I tried a few more things but the above mentiones seems to me the most logical :o).

What am I missing?

Thanks, Martin.

I have added this:

Configuration.Localization.Sources.Extensions.Add(
	new LocalizationSourceExtensionInfo("Abp",
		new XmlEmbeddedFileLocalizationDictionaryProvider(
			Assembly.GetExecutingAssembly(),
			"Adel.Portal.Localization.Portal"
		)
	)
);

to the PortalApplicationModule.PreInitialize() and added new row to the Portal.xml in Adel.Portal.Core project.

Best regards, Martin

@ismcagdas. Thanks, that did the trick. It's actually the other way round then I thought.

The code has to be indeed added to Core, not the Application project.

Thanks again for your help.

Best regards, Martin.

Question

Hello. After update of the RAD tool I am not able to add a navigation property, after clicking on the Add Navigation Property button the RAD tool freezes and restart of the Visual Studio is needed. This is happening on two different computers, so it's probably not caused by the system but rather by the data. Does RAD tool provide any crashlog? I didn't find anything useful in the crashlog of Visual studio.

Thanks. Best regards, Martin.

Open the RAD tool, click on Navigation properties tab then click Add new navigation property button and that's it.

It's ongoing project so maybe the problem is somewhere in already generated json files.

Showing 1 to 10 of 16 entries