locked
How to Customize the Identity in ASP.net Web Froms Application? RRS feed

  • Question

  • User372596098 posted

    Hello

    I created a new ASP.net Web Form Application, and I am using the .Net Identity Framewrok.

    I want to make the email (optional) at registration, I found that I need to modify the AccountViewModels.vb

    I search my project , but there is no such file

    I noticed that this file is already there for MVC projects, but not in the Web Forms Application 

    does it mean that I can not make the modification that I want !

    Thank you

    Saturday, November 25, 2017 6:44 PM

Answers

  • User475983607 posted

    Hello

    I want to make the email (optional) at registration, I found that I need to modify the AccountViewModels.vb

    Thank you

    Web Forms works a bit differently than MVC and does not pass a model from the client to the web app.  Web Forms use server controls.  You can find the Register.aspx template web form in the account folder.   You are free to change the default Account/Register.aspx web form and code behind however you like. 

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 27, 2017 1:53 PM
  • User372596098 posted

    Thank you

    I edited the create function in IdentityConfig.vb

    ' Configure validation logic for usernames
            manager.UserValidator = New UserValidator(Of ApplicationUser)(manager) With {
              .AllowOnlyAlphanumericUserNames = False
            }
            'manager.UserValidator = New UserValidator(Of ApplicationUser)(manager) With {
            '.AllowOnlyAlphanumericUserNames = False,
            '.RequireUniqueEmail = True
            '}
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 28, 2017 6:14 PM

All replies

  • User-1838255255 posted

    Hi galjabiri,

    According to your description and needs, the webform project structure is different from MVC project, I think you want to use identity with web form, please check the following samples:

    Adding ASP.NET Identity to an Empty or Existing Web Forms Project:

    https://docs.microsoft.com/en-us/aspnet/identity/overview/getting-started/adding-aspnet-identity-to-an-empty-or-existing-web-forms-project

    Create a secure ASP.NET Web Forms app with user registration, email confirmation and password reset (C#):

    https://docs.microsoft.com/en-us/aspnet/web-forms/overview/security/create-a-secure-aspnet-web-forms-app-with-user-registration-email-confirmation-and-password-reset 

    Best Regards,

    Eric Du

    Monday, November 27, 2017 7:56 AM
  • User372596098 posted

    Hello

    thank you Eric

    I think I could not express myself

    I am using Express 2015 for web, I created a web forms web application, 

    ASP.net Identity is already installed there

    what I need now is to make the email optional at registration, 

    any resource about this ?

    web forms not MVC

    thank you

    Monday, November 27, 2017 12:58 PM
  • User475983607 posted

    Hello

    I want to make the email (optional) at registration, I found that I need to modify the AccountViewModels.vb

    Thank you

    Web Forms works a bit differently than MVC and does not pass a model from the client to the web app.  Web Forms use server controls.  You can find the Register.aspx template web form in the account folder.   You are free to change the default Account/Register.aspx web form and code behind however you like. 

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 27, 2017 1:53 PM
  • User372596098 posted

    Thank you

    I edited the create function in IdentityConfig.vb

    ' Configure validation logic for usernames
            manager.UserValidator = New UserValidator(Of ApplicationUser)(manager) With {
              .AllowOnlyAlphanumericUserNames = False
            }
            'manager.UserValidator = New UserValidator(Of ApplicationUser)(manager) With {
            '.AllowOnlyAlphanumericUserNames = False,
            '.RequireUniqueEmail = True
            '}
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, November 28, 2017 6:14 PM
  • User475983607 posted

    The posted fix does not make the email address optional.  It allows multiple accounts to use the same email address which can be problematic depending the security requirements.

    Tuesday, November 28, 2017 6:28 PM
  • User372596098 posted

    Thank you mgebhard

    actually, I am not collecting the email address at registration time, I replaced it with Mobile number, and I use it as a username

    the email address in the database allows NULL, and I just ignored it at registration time

    is there another better option or technique , to do this?

    Thank you 

    Tuesday, November 28, 2017 7:32 PM