Last post Dec 08, 2017 05:15 PM by PatriceSc
Dec 08, 2017 03:04 PM|EnenDaveyBoy|LINK
Sorry the title is a little misleading, I have identity setup in the standard way, in the Account Controller you register someone with the sandard register method.
However there is a process somewhere in my project where I want to create a user automatically, all the fields are provided due to other requirements and to link all the information together there needs to be a user entity.
However i can't get the Identity Classes like the user store to work outside the account controller, so
I can build a user and insert the information into the database and send the email to the user with the information, in a normal service class without issue? and are there any risks?
Dec 08, 2017 03:58 PM|PatriceSc|LINK
But still inside your ASP.NET MVC application? You should be able to use this from anywhere. What is the problem you have ? Generally speaking, it's IMO better to always try to understand why something that should work doesn't rather than to just give up
and try something else.
Else there is not real issue. ASP.NET identity does nothing else than using the underlying provider to alter user data. You still may want to respect some rules (such as handling if the mail address is verified or not). It miight be a bit more difficult
with passwords etc... as you'll need to use again what ASP.NET identity does for handling that...
Dec 08, 2017 04:55 PM|EnenDaveyBoy|LINK
Thanks for the reply
Yes within the ASP.NET MVC application, my problem is when I use the build in Managers outside of a controller they don't save the data or there is an error because they don't accept async Task<>
I sort of know why, but I have no idea how to fix it, and tbh I don't know why it has been built in the way it has.
In terms of understanding, I don't really understand async or Task, except on a very basic concept level, I don't know how to reue the manage where i want them and I could quickly create a service which would do it.
Dec 08, 2017 05:15 PM|PatriceSc|LINK
More likely you missed the "async" modifier which is likely in the signature of your account controller and you'll need to use that as well at the other places where you need. You can then use await MyMethodAsync() to call the async APIs.
It's a quite good example IMO. Either you'll take this occasion to better understand async/await and use ASP.NET identity and later other async APIs or you'll bypass ASP.NET identity loosing the occasion of improving your programming knowledge plus making
the app uglier than needed from a design point of view, and possibly running later again and again into the same issue.