<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Single sign-on across multiple applications in ASP.NET(Asp.Net跨應(yīng)用單點登錄[轉(zhuǎn)自CodeProject])

      Introduction

      I prefer to use the Forms authentication for most of my applications. And most of my projects consist of a few relatively independent parts running on subdomains of the main domain. It would be nice to have single sign-on, so if you are logged on at www.example.com, you would be recognized also at everything.example.com.

      Forms authentication by default does not support this feature, but is not too complicated to tweak it the appropriate way.

      Behind the Forms authentication

      Technology behind the Forms authentication is simple: it would create a cookie of defined name (attribute name of forms attribute in web.config). The cookie would contain encrypted authentication data.

      To protect user's privacy and for security reasons, you can only read cookies that you wrote. They're associated with server hostname by default. But the cookie standard supports making cookies accessible for entire domain in which the server lies. It means that from server1.example.com, you can work with cookies for both server1.example.com and example.com.

      You can set domain-wide cookie only for second level domain, or for third level domain if second level domain contains three or less characters. It means that you cannot set cookie for domain "com" or "co.uk", but can for "example.com" or "example.co.uk".

      So, only what you need is to make authentication cookies domain-wide.

      Setting it up

      You must setup authentication in system.web section of your web.config file as usual, for example:

      <authentication mode="Forms">
       <forms name=".EXAMPLE-AUTH" loginUrl="/Login.aspx" 
                     protection="All" timeout="30" path="/" />
      </authentication>

      As I said before, the authentication cookie is encrypted. By default, encryption key is generated automatically. But if you need more servers to cooperate, you need to have the keys same on both servers. This can be done by adding the following to system.web section of web.config:

      <machineKey
       validationKey="BD52058A3DEA473EA99F29418689528A494DF2B00054BB7C" 
        decryptionKey="684FC9301F404DE1B9565E7D952005579E823307BED44885" 
      />

      The values of validation and decryption key should be 16 (for DES) or 48 (for TripleDES) characters long hexadecimal numbers.

      Signing on

      You must modify the authentication cookie before sending it to the client, by specifying your domain name. The code can be as follows (assumes that user has been authenticated and his name is stored in string variable UserName):

      Dim C As System.Web.HttpCookie = _
               System.Web.Security.FormsAuthentication.GetAuthCookie(UserName, False)
      C.Domain = "example.com"
      Response.AppendCookie(C)
      Response.Redirect(System.Web.Security.FormsAuthentication.GetRedirectUrl(UserName, 
                                                                                 False))

      Signing off

      Usually, there is no need to make something special to sign the user off - just call System.Web.Security.FormsAuthentication.SignOut(). But not in this case - the SignOut() method is unable to deal with domain-wide cookies.

      You need to delete the cookie manually. And the only way to delete a cookie is to set its expiration date to past. You may do it using the following code:

      Dim C As System.Web.HttpCookie = _
               Request.Cookies(System.Web.Security.FormsAuthentication.FormsCookieName)
      C.Domain = "example.com"
      C.Expires = DateTime.Now.AddDays(-1)
      Response.Cookies.Add(C)

       

      posted @ 2006-07-20 21:27  張志敏  閱讀(1620)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 国内精品综合九九久久精品| 国产在线观看网址不卡一区| 天天澡日日澡狠狠欧美老妇| 国产男女猛烈无遮挡免费视频网址| 人妻系列无码专区免费| 亚洲欧洲av一区二区| 久久这里只有精品免费首页| 97精品伊人久久久大香线蕉| 亚洲av乱码久久亚洲精品| 国产成人人综合亚洲欧美丁香花| 麻花传媒在线观看免费| 人摸人人人澡人人超碰97| 无码中文字幕人妻在线一区| 久久日产一线二线三线| 日本无产久久99精品久久| 国产69精品久久久久777| 亚洲精品精华液一区二区| 国产黑色丝袜在线播放| 鲁大师在线视频播放免费观看 | 中文字幕一区二区三区久久蜜桃| 久热这里只有精品6| 欧美丰满熟妇乱XXXXX网站| 极品少妇的粉嫩小泬视频 | 国产超碰人人做人人爰| 老司机午夜精品视频资源| 日韩高清不卡免费一区二区| 撕开奶罩揉吮奶头视频| 精品人妻av中文字幕乱| 亚洲成人四虎在线播放| 永修县| 在线天堂最新版资源| 亚洲欧洲av人一区二区| 国产精品一区二区久久岳| 国产成人精品日本亚洲网站| 四虎成人精品在永久免费| 亚洲av无码之国产精品网址蜜芽| 人妻中出无码一区二区三区| 国产日韩av二区三区| 国产一区二区日韩经典| 99RE8这里有精品热视频| 亚洲 另类 小说 国产精品无码|