PaulMiami / reCAPTCHA

reCAPTCHA 2.0 for ASPNET Core
MIT License
134 stars 37 forks source link

ASP.NET Core 3.0 support #36

Open hikalkan opened 5 years ago

hikalkan commented 5 years ago

Hi,

Any work to support ASP.NET Core 3.0?

Thanks.

taras-kolodchyn commented 5 years ago

Hi. I think the project is die.

ebicoglu commented 5 years ago

if any new reCaptcha library that supports .Core 3.0 comes up please notify me !

IInvocation commented 5 years ago

Hi, seems like there's simply some kind of change in the way that views are rendered in development. In production - the library is working as intended (though i have "CompileOnPublish" deactivated by default for another reason).

If you want to continue using it - and don't mind missing the feature during development - you can easily create a custom attribute, that ignores captcha-validation for the Development-Environment: using System; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using PaulMiami.AspNetCore.Mvc.Recaptcha;

namespace FluiTec.AppFx.WildServer.Attributes { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class ValidateRecaptchaAttributeIgnoreDevelopment : Attribute, IFilterFactory, IOrderedFilter { public bool IsReusable => true;

    public int Order { get; set; }

    public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
    {
        var environment = serviceProvider.GetRequiredService<IWebHostEnvironment>();
        if (!environment.IsDevelopment())
            return serviceProvider.GetRequiredService<ValidateRecaptchaFilter>();
        return new DontValidateRecaptchaFilter();
    }
}

public class DontValidateRecaptchaFilter : IFilterMetadata
{

}

}

PaulMiami commented 4 years ago

I have published a new version compatible with aspnet core 3.1, Let me know if you find any issues with it