簡體   English   中英

自定義用戶身份驗證ASP.net MVC在服務器上不起作用

[英]Custom user authentication ASP.net MVC not working on server

我已經在一個項目中使用了一個教程,但遇到了一個問題,即用戶角色無法在服務器上更新。 在本地,一切正常,但是當發布到Azure服務器時,角色不會更新。 我使用了本教程: Custom-Authentication-asp-net-MVC

這是我的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>

我已經在線閱讀了我的web.config文件中可能缺少的內容,但是我在用戶管理方面經驗不足。 任何人都可以幫忙。

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

您確定連接字符串正確嗎? 請與我們分享您的連接字符串。

這可能是因為這種用法

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

更改為:

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

我找到了我在角色管理器上缺少applicationname屬性的答案,因此:

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

應該

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

真正令我震驚的是在嘗試此修復程序時添加了.azurewebsites.net

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM