IdentityManager / IdentityManager.AspNetIdentity

ASP.NET Identity support for Thinktecture IdentityManager
Apache License 2.0
60 stars 51 forks source link

How to integrate AspNetIdentity within an existing application #1

Closed FANlinghua closed 9 years ago

FANlinghua commented 10 years ago

I tried integrated AspNetIndentity with an existing application. I added same Config folder with two files (AspNetIdentityIdentityManagerFactory and CustomDbContext) and change Startup() adding Configuration:

    public void Configuration(IAppBuilder app)
    {
        //ConfigureAuth(app);
        //var factory = new Thinktecture.IdentityManager.Host.AspNetIdentityIdentityManagerFactory("SegicConnectionString");
        var factory = new Thinktecture.IdentityManager.Host.AspNetIdentityIdentityManagerFactory("AspId");

        app.UseIdentityManager(new IdentityManagerConfiguration()
        {
            IdentityManagerFactory = factory.Create
        });

Installed the new version AspNetIdentity 1.0.0-alpha-9: Install-Package Thinktecture.IdentityManager.ASPNETIDENTITY –Pre, and added this package to the reference of project and I have some compile errors as follow:

Error 3 The type 'Thinktecture.IdentityManager.IIdentityManagerService' is defined in an assembly that is not referenced. You must add a reference to assembly 'Thinktecture.IdentityManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. C:\TFS\SEGIC in-a-box\Website\Trunk\Alcero.Segic.Website\Config\AspNetIdentityIdentityManagerFactory.cs 33 13 Alcero.Segic.Website Error 4 The best overloaded method match for 'Thinktecture.IdentityManager.DisposableIdentityManagerService.DisposableIdentityManagerService(Thinktecture.IdentityManager.IIdentityManagerService, System.IDisposable)' has some invalid arguments C:\TFS\SEGIC in-a-box\Website\Trunk\Alcero.Segic.Website\Config\AspNetIdentityIdentityManagerFactory.cs 35 20 Alcero.Segic.Website Error 5 Argument 1: cannot convert from 'Thinktecture.IdentityManager.AspNetIdentity.AspNetIdentityManagerService<Microsoft.AspNet.Identity.EntityFramework.IdentityUser,string,Microsoft.AspNet.Identity.EntityFramework.IdentityRole,string>' to 'Thinktecture.IdentityManager.IIdentityManagerService' C:\TFS\SEGIC in-a-box\Website\Trunk\Alcero.Segic.Website\Config\AspNetIdentityIdentityManagerFactory.cs 35 57 Alcero.Segic.Website

if I included Thinktecture.IdentityManager.AspNetIdentity project into the solution and reference this project, the no error but it seems can not run Startup, even I set breakpoint on Configuration(), but can't go to there, I can see the title of web page is Thinktecture IdentityManager, but the url is existing application URL.

I tried to figure out for several days but can't, could you please let me know what I missing? how to using this tool into existing application

in the web.config I set connectString as follow:

  <add name="AspId" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=IdSvrAspNetIdentity;Integrated Security=True" providerName="System.Data.SqlClient" />

What else I need change?

Thanks

FANlinghua commented 10 years ago

If I use the same web.config, then can load Thinktecture IdentityManager page to Manage your identities.

But still can not create User and Searching, An error has occurred.

brockallen commented 10 years ago

This is most likely due to my build script not internalizing the appropriate assemblies. I'll leave this issue open to investigate/fix. Thx.

brockallen commented 10 years ago

Ok, I just tried to reproduce and could not. I created a new web project and installed owin/system.web, asp.net identity ef, and then idmgr w/ aspnet identity and essentially copied over the config files as the sample and it's all working fine. The last thing I had to do is enable RAMMFAR: http://www.hanselman.com/blog/BackToBasicsDynamicImageGenerationASPNETControllersRoutingIHttpHandlersAndRunAllManagedModulesForAllRequests.aspx

brockallen commented 10 years ago

Any updates?