Base solution for your next web application

Activities of "peabaw"

Hi

We have encountered a problem where PK int ID of an entity suddenly moves +1000 steps. Example: 1 2 3 1003 1004 2004 2005

This seems to be an issue related to the way Sql Server handles Identity column on a restart/reload: Consecutive values after server restart or other failures - SQL Server might cache identity values for performance reasons and some of the assigned values can be lost during a database failure or server restart. This can result in gaps in the identity value upon insert. If gaps are not acceptable then the application should use its own mechanism to generate key values. Using a sequence generator with the NOCACHE option can limit the gaps to transactions that are never committed. https://docs.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql-identity-property?view=sql-server-2017

Normally, this is not an issue. Our customer, however, needs a sequence that moves along in a more linear matter.

How would you do it? T-Sql Sequence, EF Sequence (or other magic) or any other solution (the ABP/Zero way)?

We need to dynamically create the language texts.

@maliming: Do you mean to work directly to the database and insert string that way?

Hello there

The LanguageAppService gives us a possibility to edit a language text:

public async Task UpdateLanguageText(UpdateLanguageTextInput input)

But why is there no Create?

public async Task CreateLanguageText(CreateLanguageTextInput input)

I guess there is a very good reason for that that I missed, so please hit me in the head with that explenation!

I'm asking because we need to dynamically create translatable language texts from the GUI to be used in the application. We are creating forms with 1..N inputs with labels, and these labels must be translatable. I thought I would be able to use the language DB in Zero and just create then through API but am I right that I need to implement a separate DB for this?

Solution: Asp.Net Zero angular+webapi

@alper

I think all of those links concerns Windows authentication only unfortunately. I have yet to find a guide for BOTH Windows and Anonymous authentication, especially with Angular och WebApi.

My conclusion is that this might actually not be possible to do. Any ideas to "a workaraound"? Two sites, one each for every login? Some sort of external login solution who does the dual-authentication (i.e. first Windows, then forms login)?

Ah, that got me going in the right way. It now works.

It had also to add my Module to the WebCoreModule:

[DependsOn(
    ...
        typeof(GHRIntegrationModule),
   ....
       )]
    public class GHRWebCoreModule

And lastly add this to WebCoreModule.PreInitialize():

Configuration.Modules.AbpAspNetCore()
                .CreateControllersForAppServices(
                    typeof(GHRIntegrationModule).GetAssembly()
                );

Thank you @ryancyq!

Hi

I have created a separate VS Project called Integrations. In this I have created a Module:

public class GHRIntegrationModule : AbpModule
    {
        public override void PreInitialize()
        {
            var configurationAccessor = IocManager.Resolve<IAppConfigurationAccessor>();
            var connectionString = configurationAccessor.Configuration["ConnectionStrings:ProjectSearch"];

            if (string.IsNullOrEmpty(connectionString))
            {
                //Use fake project search if database connection string is empty
                IocManager.Register<IProjectDataProvider, FakeProjectDataProvider>(DependencyLifeStyle.Singleton);
            }
            else
            {
                IocManager.Register<IProjectDataProvider, ProjectDataProvider>(DependencyLifeStyle.Singleton);
                var projectDataProvider = Configuration.Get<ProjectDataProvider>();
                projectDataProvider.DbConnectionString = connectionString;
            }
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(GHRIntegrationModule).GetAssembly());
        }
    }

The project currently contains a single AppService:

[AbpAuthorize]
    public class ProjectAppService : IProjectAppService
    {
        private readonly IProjectDataProvider _projectDataProvider;

        public ProjectAppService(IProjectDataProvider projectDataProvider)
        {
            _projectDataProvider = projectDataProvider;
        }

        [AbpAuthorize]
        public async Task<ProjectDto> GetProject(GetProjectInput input)
        {
            return await _projectDataProvider.GetProject(input);
        }

        [AbpAuthorize]
        public async Task<List<ProjectDto>> SearchProjects(SearchProjectInput input)
        {
            return await _projectDataProvider.SearchProjects(input);
        }
    }

I thought that the AppService would be picked up by the auto API controller creator and included in the API but it does not show up in Swagger for example so something is missing.

I have tried to add a call to create the controller for the app service but no change. I tried to add the following to the WebCoreModule PreInitialize and my own module's PreInitialize:

Configuration.Modules.AbpAspNetCore()
                .CreateControllersForAppServices(
                    typeof(GHRIntegrationModule).GetAssembly()
                );

I think I am only missing something easy and obvious.

Any tips wpuld be very appreciated!

@ismcagdas

Thank you for all help. Might I just bother you to explain why it might be possible with MVC but not possible with Angular? It might help give me a clue.

Hi @ismcagdas

Unfortunately no. I think the AlwaysTrueExternalAuthSource method will not work on a site with both Windows Auth and Anonymous access. I think it will only work on a site with only Windows Auth. In the db the source is AlwaysTrueExternalAuthSource instead of LDAP which might cause the password error as well.

What I want to do seems to be a special case (thought it would be a common scenario for an entreprise solution to allow local user access and forms login for external users but I seem to be wrong).

I do not have a good lead going forward or any reserve backup plan though. Any tips would therefore be very appreciated!

I tried and added [Authorized] before the Authenticate method:

[Authorize] public async Task<AuthenticateResultModel> Authenticate([FromBody] AuthenticateModel model)

I now get a populated User.Identity, but it now however fails with "Authorization.Users.UserManager - Invalid password for user X." so I guess something else has gone wrong now.

Am I doing it the right way or should I completely change approach?

Hello there

I have some problems getting Windows AND anonymous authentication to work. The login process is supposed to be like this:

  1. The user go to the angular site login. It should start an automatic AD/LDAP login process (as described at https://support.aspnetzero.com/QA/Questions/5370).
  2. If successful AD login, the user gets in.
  3. If unsuccessful, the user should return to the login page and be able to login using username and password as normal.

I have gotten some of this to work but when both Anonymous and Windows autentication is active in IIS, the User.Identity.IsAuthenticated is always false making LDAP login always unsuccessful.

I have changed the API web.config attribute forwardWindowsAuthToken="true".

I'm quite new to both IIS with .Net Core and especially Angluar, so any tips would be greatly appreciated!

Best regards // Andreas

Showing 11 to 20 of 22 entries