-
Dec 27th, 2023, 10:20 PM
#1
Thread Starter
New Member
[RESOLVED] .NET Core Razor Page(Identity) - Employing a second model and db update
Good day/evening,
I'm using Microsoft Identity as part of my MVC web application solution and allowing users to upload a mobile phone number.
The issue I am having is in the implementation of the verification process. What I did was to create a second OnPost method where I would like to save some system generated values to the db. My preference is to not implement a page model for these values as they will never factor in in the page lifecycle. The OnPost method I mentioned will upload these values to a non-identity-related table to the db, send an email, then redirect to another page where the user will enter a phone code to confirm authenticity.
My issue is the phone Model that is tied to the page. I'm using dependency injection to save the phone number, but I can't seem to be able to implement a solution that will upload the values to the new table I described. See the following snippets of code:
phone.cshtml.cs
Code:
public class PhoneModel(UserManager<IdentityUser> userManager, IConfiguration iConfig) : PageModel
{
private readonly UserManager<IdentityUser> _userManager = userManager;
private readonly IConfiguration _config = iConfig;
private readonly ApplicationDbContext _db;
public VerifyMobilePhone verifyMobilePhone { get; set; }
public VerifyMobilePhoneModel(ApplicationDbContext db)
{
_db = db;
}
[BindProperty]
public InputModel Input { get; set; }
public class InputModel
{
[Display(Name = "Phone number")]
[RegularExpression(@"\(\d\d\d\) \d\d\d - \d\d\d\d")]
public string PhoneNumber { get; set; }
public bool PhoneNumberConfirmed { get; set; }
}
private async Task LoadAsync(IdentityUser user)
{..ok..}
public async Task<IActionResult> OnGetAsync()
{..ok..}
public async Task<IActionResult> OnPostUpdatePhone()
{..ok..}
public async Task<IActionResult> OnPostSendPhoneCode()
{
var salt = **Generate Salt**
var phoneVerifyCodeHash = **Generate Phone**
var user = await _userManager.GetUserAsync(User);
**THIS IS WHERE I WANT TO UPLOAD THESE 3 FIELDS TO THE NEW TABLE IN MY DB**
**Redirect to Phone code input page**
}
The area that's highlighted red is giving me the following error to which I am unable to resolve:
"CS8862: A constructor declared in a type with parameter list must have 'this' constructor initializer."
I am unable to figure out how to tackle this issue.
Any pointers?
Thanks,
Kenobi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|