2016-04-01 11 views
0

フォームの認証済みWebサイトのWeb設定ファイルに以下のようなファイルがありますが、ログインしない限り、そのページに移動することはできません。Web設定で作業できない

<configuration> 
    <connectionStrings> 
    <remove name="******"/> 
    <add name="*******" *******"/> 
    <add name="*****" *******"/> 
    </connectionStrings> 
<location path="About.aspx"> 
    <system.web> 
     <authorization> 
     <allow users="*" /> 
     </authorization> 
    </system.web> 
    </location> 

ASP.net Webフォーム4のサイト。 NOTE ***元のデータを隠す

答えて

0

ご質問、それは明確ではない.But、再びこのラインに

<system.web> 
    <!--Session state Time Out--> 
    <sessionState timeout="60" /> 
    <!--My authontication module--> 
    <authentication mode="Forms"> 
     <forms name="PROJECTNAME.ASPXAUTH" loginUrl="~/Login.aspx" protection="All" path="/" timeout="60"/> 
    </authentication> 
    <authorization> 
     <deny users="?" /> 
    </authorization> 
</system.web> 

を追加することにより、認証から有効にして、その後、任意の特定のフォルダにアクセスしたいapplication.Ifこれは、Webを確保しますフォルダを作成して、Web.configファイルを追加file.and web.cofigファイル内

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
     <authorization> 
     <!--Defualt access grant sa=11,admin=12--> 
     <allow roles="admin"/> 
     <!--Order and case are important below--> 

     <deny users="*"/> 
     </authorization> 
    </system.web> 
</configuration> 

管理

以外の役割のユーザーのアクセスを防止

とロールを作成

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
         1, // Ticket version 
         Convert.ToString(user.UserID), // Username associated with ticket 
         DateTime.Now, // Date/time issued 
         DateTime.Now.AddMinutes(60), // Date/time to expire 
         false, // "true" for a persistent user cookie 
         Convert.ToString(user.RoleID), // User-data, in this case the roles 
         FormsAuthentication.FormsCookiePath);// Path cookie valid for 

        // Encrypt the cookie using the machine key for secure transport 
        string hash = FormsAuthentication.Encrypt(ticket); 
        HttpCookie cookie = new HttpCookie(
         FormsAuthentication.FormsCookieName, // Name of auth cookie 
         hash); // Hashed ticket 

        // Set the cookie's expiration time to the tickets expiration time 
        if (ticket.IsPersistent) cookie.Expires = ticket.Expiration; 

        // Add the cookie to the list for outgoing response 
        Response.Cookies.Add(cookie); 
関連する問題