2015-05-15 79 views
1

我有兩個應用,一個叫www.domain.dk和m.domain.dkFormsAuthentication加密/解密

他們兩人有一個登錄功能(相同的),但是如果你登入m.domain。 DK和去www.domain.dk那麼它需要記住,你已經登陸,

這裏來的問題..

WWW罰球和錯誤說,它不能從驗證數據由m站點設置的cookie,所以我開始調試代碼,發現www在加密FormsAuthenticationTicket時,加密的字符串比干擾字符長64個字符在m站點做它。

以下部分從web.config是這兩個項目

<machineKey validationKey="CF3D..." decryptionKey="A56..." validation="SHA1" decryption="AES" /> 

<authentication mode="Forms"> 
    <forms name=".ASPXAUTH" domain=".domain.dk" timeout="20" enableCrossAppRedirects="true" path="/" protection="All" cookieless="UseCookies" /> 
</authentication> 

下面的代碼是從登錄功能

var ticket = new FormsAuthenticationTicket(1, user.UserName, DateTime.Now, DateTime.Now.AddMinutes(20), false, string.Empty, "/"); 
var hashCookies = FormsAuthentication.Encrypt(ticket); 

www是一箇舊網站相同的,所以我的問題主要是是否還有其他可以影響「FormsAuthentication.Encrypt」的東西,而不是我在web.config中的東西?

回答

0

的解決方案是

compatibilityMode="Framework20SP1" 

添加到的machineKey標籤