Base solution for your next web application

Activities of "ismcagdas"

Hi,

You should do it when opening the modal dialog.

Hi,

Sorry for the delay, I had a chance to take a look at this today. I have figured out how to do this. And this problem is not totaly related to ABP or ABP Zero.

I have followed the steps in this nice article <a class="postlink" href="https://dotnetcodr.com/2015/11/16/wiring-up-a-custom-authentication-method-with-owin-in-web-api-part-1-preparation/">https://dotnetcodr.com/2015/11/16/wirin ... eparation/</a>, you can read this article to understand how this works. You can skip the first part. It's just for creating an empty project.

This article explains how to create and use a custom owin authentication middleware. The previous approach I suggested using a custom AuthorizeFilter was wrong, you can delete it.

And these are the changes I have made this to work.

  1. I have created below classes in my project.
public class MyAuthenticationHandler : AuthenticationHandler<HttpHeaderBasedAuthenticationOptions>
{
    protected override Task<AuthenticationTicket> AuthenticateCoreAsync()
    {
        bool authorized = true;
        if (authorized)
        {
            AuthenticationProperties authProperties = new AuthenticationProperties();
            authProperties.IssuedUtc = DateTime.UtcNow;
            authProperties.ExpiresUtc = DateTime.UtcNow.AddDays(1);
            authProperties.AllowRefresh = true;
            authProperties.IsPersistent = true;

            IList<Claim> claimCollection = new List<Claim>
            {
                new Claim(ClaimTypes.NameIdentifier, "2"),
                new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "2"),
                new Claim(AbpClaimTypes.TenantId, "1"),
                new Claim(ClaimTypes.Name, "admin"),
                new Claim(ClaimTypes.Surname, "admin"),
                new Claim(ClaimTypes.Email, "[email protected]"),
            };

            ClaimsIdentity claimsIdentity = new ClaimsIdentity(claimCollection, "Custom");
            AuthenticationTicket ticket = new AuthenticationTicket(claimsIdentity, authProperties);
            return Task.FromResult(ticket);
        }

        return null;
    }
}
public class HttpHeaderBasedAuthenticationOptions : AuthenticationOptions
{
    public HttpHeaderBasedAuthenticationOptions() : base("x-company-auth")
    {
        
    }
}
public class HttpHeaderBasedAuthMiddleware : AuthenticationMiddleware<HttpHeaderBasedAuthenticationOptions>
{
    public HttpHeaderBasedAuthMiddleware(OwinMiddleware nextMiddleware, HttpHeaderBasedAuthenticationOptions authOptions)
        : base(nextMiddleware, authOptions)
    { }

    protected override AuthenticationHandler<HttpHeaderBasedAuthenticationOptions> CreateHandler()
    {
        return new MyAuthenticationHandler();
    }
}
public static class HttpHeaderAuthenticationExtension
{
    public static void UseHttpHeaderBasedAuthentication(this IAppBuilder appBuilder)
    {
        appBuilder.Use<HttpHeaderBasedAuthMiddleware>(new HttpHeaderBasedAuthenticationOptions());
    }
}

After creating these classes, in Startup.cs add this line

app.UseHttpHeaderBasedAuthentication();

And remove the line which starts with

app.UseCookieAuthentication.....

If you dont want user's to see Login page, you have to manually check AbpSession.UserId and if it's bigger than 0, redirect user to application. Or in your case, since you dont need it you can just delete it.

Please let me know of your progress.

Hi,

Which version of ABP do you use ? And is there any exception message in Logs.txt file. You can search your web project folder to find it.

If there is an error, I think it happens outside of your try-catch block. ABP must handle it an log it into Logs.txt file.

Hi,

Can you try to do it like this to see if it is saved or not. Check the value of Id after SaveChangesAsync called.

var test = new TestEntity {...};
 await _testRepository.InsertAsync(test);
 await CurrentUnitOfWork.SaveChangesAsync();
 var id = test.Id;

Since the Action is transactional, the record is inserted to the database but you cannot see it until the transaction completes which is not related to ABP.

Hi,

ABP does not offer such a build in feature for now. I would create two different services for this and assign different permissions to each and decide which service to call on the client side according to current user's permissions.

Maybe seperating views and make common parts reusable components would be even better.

Hi,

You can use token based authentication for your other apps. See <a class="postlink" href="https://aspnetzero.com/Documents/Development-Guide#token-based-authentication">https://aspnetzero.com/Documents/Develo ... entication</a>

Hi,

When setting

Configuration.UnitOfWork.IsTransactional = false;

in the PreInitialize of WebModule made it all working for me.

It seems like it's not possible to use distributed transactions with this one.

Answer

Hi,

Does any of your jobs are accessing a different database ? If so it might be a MSDTC problem. MSDTC service must be up and running. If your SQL Server is on a different server, then MSDTC service must be up and running on both machines.

If not, does this happen randomly or is it always in this way ?

Hi,

According to this stackoverflow answer <a class="postlink" href="http://stackoverflow.com/a/36047232/6681451">http://stackoverflow.com/a/36047232/6681451</a>, you can set "Always On" property to "On" in your web app settings.

But if you have a VM and access to IIS, then you can configure it in IIS as well.

Answer

Hi,

Can you share your routing definition as well. Maybe we can findout something.

Showing 12161 to 12170 of 12740 entries