1

I'm in the early stages of building an app with MVC 5. I haven't used this version of the framework yet, nor ASP.NET Identity (I'm not even sure if that's relevant to my problem). I want to temporarily, temporarily, hard code a user in the web.config as follows:

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="2880">
    <credentials passwordFormat="Clear">
      <user name="name" password="password"/>
    </credentials>
  </forms>
</authentication>

I've used that previously, and it's worked as expected. In this app, however, it's not working. In AccountController.cs, in the method Login(), it appears that an object of type UserManager can't find the user I specified in web.config, probably because that object isn't looking in web.config.

So, how I do re-enable using the user specified in web.config? Please provide steps.

I completely understand that this not a good practice. It's only temporary to get something else working.

ageektrapped
  • 14,482
  • 7
  • 57
  • 72
  • Asp.Net Identity completely replace FormsAuthentication, therefore anything you try to do with FormsAuthentication will be unknown to Asp.Net Identity. – Erik Philips May 22 '14 at 20:04
  • @ErikPhilips - Correct. However, I believe it may have more to do with the OWIN middleware than strictly ASP.NET Identity. (http://blogs.msdn.com/b/webdev/archive/2013/07/03/understanding-owin-forms-authentication-in-mvc-5.aspx) You should be removing the module, as specified here: http://stackoverflow.com/questions/21652808/asp-net-mvc-5-web-config-formsauthenticationmodule-or-formsauthentication – user1417835 May 22 '14 at 23:27
  • 1
    @ErikPhilips OK, then. How about this? Is there a way I can do something similar with ASP.NET Identity? I.e. hardcode a user account somewhere. – ageektrapped May 23 '14 at 12:35
  • Maybe create a controller method that creates an external claims/bearer token for login? Either way the user really should exist in the DB. – Erik Philips May 23 '14 at 14:57
  • The Seed() method, perhaps? I'll look into that. Thanks Erik. – ageektrapped May 23 '14 at 18:44

0 Answers0