简体   繁体   中英

Custom user authentication ASP.net MVC not working on server

I have made use of a tutorial in a project and I'm running into an issue where user roles do not update on the server. Locally everything works fine but when published to an Azure server the roles do not update. I made use of this tutorial: Custom-Authentication-asp-net-MVC

Here is my web.config:

<membership defaultProvider="CustomMembership">
  <providers>
    <clear />
    <add name="CustomMembership" type="YouAndMeRealty.Authentication.CustomMembership" />
  </providers>
</membership>
<roleManager defaultProvider="CustomRole" enabled="true" >
  <providers>
    <clear />
    <add name="CustomRole" type="YouAndMeRealty.Authentication.CustomRoles" />
  </providers>
</roleManager>

I've read online that it may be that I am missing something in my web.config, but I am very inexperienced in user management. Please can anyone help.

    <connectionStrings>  
    <add name="AuthenticationDB" connectionString=" Data Source=.;Initial Catalog=CustomAuthenticationDB;Integrated Security=True" providerName="System.Data.SqlClient" />  
  </connectionStrings>  

Did you sure that your connectionstring is right ? Please share your connectionstring with us .

And its maybe because of this usage

  <providers>
    <clear />
    <add name="CustomRole" type="YouAndMeRealty.Authentication.CustomRoles" />
  </providers>

change as :

 <providers>
    <clear />
    <add name="CustomRole" type="YouAndMeRealty.Authentication.CustomRole" />
  </providers>

I found the answer I was missing the applicationname attribute on the the role managers so:

<providers>
<clear />
<add name="CustomRole" type="YouAndMeRealty.Authentication.CustomRole" />

Should be

<providers>
    <clear />
    <add name="CustomRole" type="YouAndMeRealty.Authentication.CustomRoles" applicationName="sitename.azurewebsites.net"/>
  </providers>

What really tripped me up was adding the .azurewebsites.net as I had attempted this fix

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM