ASP.NET Identity using Oxygene

ASP.NET Identity using Oxygene

Postby fritsr » Mon 18 Jul 2016 08:52

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/docs/Identity-2-Tutorial.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.
fritsr
 
Posts: 22
Joined: Tue 30 Oct 2007 03:49

Re: ASP.NET Identity using Oxygene

Postby Shalex » Tue 19 Jul 2016 13:01

1. You are walking through https://www.devart.com/dotconnect/mysql/docs/Identity-2-Tutorial.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/docs/?Identity-2-Tutorial-Entity.html. Does it work?
Shalex
Devart Team
 
Posts: 7377
Joined: Thu 14 Aug 2008 12:44

Re: ASP.NET Identity using Oxygene

Postby fritsr » Tue 19 Jul 2016 15:29

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 !
fritsr
 
Posts: 22
Joined: Tue 30 Oct 2007 03:49

Re: ASP.NET Identity using Oxygene

Postby Shalex » Tue 26 Jul 2016 09:59

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).
Shalex
Devart Team
 
Posts: 7377
Joined: Thu 14 Aug 2008 12:44

Re: ASP.NET Identity using Oxygene

Postby fritsr » Sun 31 Jul 2016 20:02

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.
fritsr
 
Posts: 22
Joined: Tue 30 Oct 2007 03:49

Re: ASP.NET Identity using Oxygene

Postby Shalex » Mon 01 Aug 2016 08:15

Thank you for your feedback.
Shalex
Devart Team
 
Posts: 7377
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for MySQL