Page 1 of 1

ASP.NET Identity using Oxygene

Posted: Mon 18 Jul 2016 08:52
by fritsr
I'm using Remobjetcs Oxygene with the Devart DotConnect MySQL driver to build an ASP.NET website with Identity 2.0.

I've managed to translate the tutorial on https://www.devart.com/dotconnect/mysql ... orial.html
to Oxygene.

I'm stuck at the line
var manager := new ApplicationUserManager(new MySqlUserStore);

A few lines above a contrustor for ApplicationUserManager is declared:
constructor ApplicationUserManager(store: IUserStore<ApplicationUser>);

A MySQLUserStore is apparently not of type IUserStore<ApplicationUser>. A cast to this type gave a runtime error.

Any tips?
Frits Regtien.

Re: ASP.NET Identity using Oxygene

Posted: Tue 19 Jul 2016 13:01
by Shalex
1. You are walking through https://www.devart.com/dotconnect/mysql ... orial.html > the "Using Existing ASP.NET Identity Functionality" section, aren't you?
We cannot reproduce the issue at the moment. Please specify:
a) the exact text of the error and its full stack trace
b) the version of your Visual Studio
c) send us a test project for reproducing. In case of >2MB attachment, we recommend either using some file exchange server (send us the corresponding link) or uploading a test project to our FTP server (the credentials will be provided by email request)
d) what product from the http://www.remobjects.com/downloads/ list should we install?

2. As a workaround, try using https://www.devart.com/dotconnect/mysql ... ntity.html. Does it work?

Re: ASP.NET Identity using Oxygene

Posted: Tue 19 Jul 2016 15:29
by fritsr
1 right
a)
this code does not compile:
var manager := new ApplicationUserManager(new MySqlUserStore);
this code gives an error:
var manager := new ApplicationUserManager(MySqlUserStore.create() as IUserStore<ApplicationUser>);
Cannot cast an object of Devart.Data.MySql.Web.Identity.MySqlUserStore to the type Microsoft.AspNet.Identity.IUserStore`1[TCOtaxi6.Models.ApplicationUser].
b) I'm using Visual Studio 2015 Community.
c) I did send you a OneDrive link.
d) you can download http://www.elementscompiler.com/elements/download.aspx from RemObjects

Thanks for investigating !

Re: ASP.NET Identity using Oxygene

Posted: Tue 26 Jul 2016 09:59
by Shalex
The tutorial uses a synonym for type

Code: Select all

using ApplicationUser = Devart.Common.Web.Identity.IdentityUser;
but your code creates a successor

Code: Select all

ApplicationUser = public class(Devart.Common.Web.Identity.IdentityUser)
We have not found a syntax for synonyms in Oxygene, so we replaced all ApplicationUser entries with Devart.Common.Web.Identity.IdentityUser (see the project we have just sent to you by email).

Re: ASP.NET Identity using Oxygene

Posted: Sun 31 Jul 2016 20:02
by fritsr
Thanks a lot for your answer. I think it put me in the right direction.

I think I've found the syntax for synonyms. It is rather simple:

Code: Select all

type
  ApplicationUser = Devart.Common.Web.Identity.IdentityUser;
You can add methods to ApplicationUser as follows:

Code: Select all

 extension method ApplicationUser.GenerateUserIdentity(manager: ApplicationUserManager): ClaimsIdentity;
  extension method ApplicationUser.GenerateUserIdentityAsync(manager: ApplicationUserManager): Task<ClaimsIdentity>;
My project is not finished, but so far it seems to work.

Re: ASP.NET Identity using Oxygene

Posted: Mon 01 Aug 2016 08:15
by Shalex
Thank you for your feedback.