2

I am trying to use ASP.NET Identity with a web form (NOT ASP.NET MVC). I want to use the user name to authenticate, not the email address. I have tried all the answers for this same issue with ASP.NET MVC, but I cannot get anything to work after hours of working on this.

How do I do this?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Please include a [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). Please also read [How do I ask a Good Question](http://stackoverflow.com/help/how-to-ask). Make sure that your questions are specific and not overly broad. – Igor Apr 08 '16 at 20:45

1 Answers1

1

I haven't used Web Forms in a while, but since Web Forms aren't there in the new ASP.NET Core, have you tried older tutorials on Identity for ASP.NET Web Forms?

Here's an old tutorial I found:

Note that the username is a text string (not an email address), so this article may help you even if you have to do things a little differently in Visual Studio 2015.

Let me know if that doesn't work, then I can try to dig deeper and see if I can help translate the older instructions to something you can use today.

I found a tutorial from Dec 2015 for using the username instead of email:

Using User Name Instead of Email in ASP.NET Identity - CodeProject http://www.codeproject.com/Articles/1052354/Using-User-Name-Instead-of-Email-in-ASP-NET-Identi

To summarize, it suggests the following:

  1. Update the view models for login & registration
  2. Update the login-related action methods
  3. Update the views that use the models

There are also additional suggestions in these older Stack Overflow questions that may help:

Community
  • 1
  • 1
Shahed C - MSFT
  • 2,831
  • 23
  • 26
  • Thanks for the post Shahed. The link is from a post in 2013 so it's a bit outdated. I am going to post a new question with some code from the current v of identity. Two basic quesitons: 1. How to change validation to allow text without @ in the email field or how to use username field for the validation instead of email. – noCodeMonkeys Apr 08 '16 at 21:35
  • 1
    ok, let me know the link to the new question in case I can help there. As for your question about changing the the validation to username instead of email, I found a newer tutorial, so I'll edit my response to include more info. – Shahed C - MSFT Apr 09 '16 at 20:27
  • 1
    Thanks very much for that. Those links are good, but again they are for MVC apps. The answer turns out to be embarrassingly simple as I post here. http://stackoverflow.com/questions/36509992/using-asp-net-identity-with-web-forms-how-to-validate-with-username-instead-of/36524917#36524917 – noCodeMonkeys Apr 10 '16 at 02:06
  • It's all good. You got it working and that's what's important! :) – Shahed C - MSFT Apr 10 '16 at 02:23