2013-07-20 105 views
1

我已創建了互聯網應用的模板, ASP.net MVC4應用,並希望List<T>屬性添加到由ASP內建形式Authetication提供MembershipUser對象。添加列表<T>屬性ASP.net MembershipUser對象MVC 4

此列表屬性將是StockPermission對象的列表:

public class StockPermission 

    { 

     private Stock stock;   
     private byte afterSaveAction;   
     private bool allowEditingStockDocs; 
     private bool allowChangingUser; 
    } 

因此我的MembershipUser將包含StockPermission對象 這讓的MembershipUser在列表與這些股票進行定義的動作

回答

0

開始之前試圖做這樣的事情,你最好仔細閱讀這些系統是什麼。從你的評論中可以清楚地看出,你並沒有真正理解它們,因爲你混淆了多個系統。

FormsAUthentication與MembershipUser無關。 FormsAuthentication只是爲每個Web請求提供一個cookie來顯示爲已驗證身份。 FormsAuthentication可以用於任何類型的憑證系統。

MembershipUser是Membership子系統的一部分。 Membership與FormsAuthentication無關,除了您的代碼會調用Membership來驗證用戶憑據,那麼您的代碼將使用FormsAuthentication創建一個cookie來記錄用戶。

您想要進行的更改與權限和權限不是會員系統的一部分,它們是角色系統的一部分。由於某些原因,這些系統是分開的,因爲它們可以用自定義實現來替換。並且它們具有邏輯上不同的功能。

最後,您不能更改MembershipUser,因爲它是基本框架的一部分。您可以通過從MembershipUser派生自己的類來擴展它,但這不是推薦的做事方式。相反,您應該擁有自己的User類,它引用了MembershipUser.ProviderUserId。

簡而言之,您即將深入瞭解框架的內部。如果沒有更多瞭解這是什麼,這是不應該做的。

相關問題