Lm th? no ?: Ki?m sot ?y quy?n quy?n trong m?t ASP.NET Application

D?ch tiu ? D?ch tiu ?
ID c?a bi: 316871 - Xem s?n ph?m m bi ny p d?ng vo.
Bung t?t c? | Thu g?n t?t c?

? Trang ny

TM T?T

S? d?ng ny h?ng d?n t?ng b?c ? p d?ng cc t? kha <location>trong Tp tin Web.config c?u h?nh truy c?p vo m?t t?p tin c? th? v m?c tin th thoai.

Khi s? d?ng cc h?nh th?c d?a trn xc th?c trong ASP.Cc ?ng d?ng m?ng, ch? c ng?i dng xc th?c ?c c?p quy?n truy c?p vo cc trang trong ?ng d?ng. Unauthenticated ng?i dng t? ?ng ?c chuy?n ?n trang ?c ch? ra b?i cc thu?c tnh loginUrl c?a t?p tin Web.config ni h? c th? g?i thng tin k nh?p c?a h?. Trong m?t s? tr?ng h?p, b?n c th? cho php ng?i dng truy c?p cc trang nh?t ?nh trong m?t ?ng d?ng m khng yu c?u xc th?c.

</location>

C?u h?nh truy c?p vo m?t t?p tin c? th? v m?c tin th thoai

  1. Thi?t l?p d?a trn cc h?nh th?c xc th?c.? bi?t thm chi ti?t, b?m vo nh?ng con s? bi vi?t d?i y ? xem cc bi vi?t trong c s? ki?n th?c Microsoft:
    308157 Lm th? no ?: Th?c hi?n d?a trn cc h?nh th?c xc th?c trong ASP c?a b?n.NET ?ng d?ng b?ng cch s? d?ng Visual Basic.NET
    301240 Lm th? no ?: Th?c hi?n d?a trn cc h?nh th?c xc th?c trong ASP c?a b?n.NET ?ng d?ng b?ng cch s? d?ng C#.NET
  2. Yu c?u b?t k? trang no trong ?ng d?ng c?a b?n ? ?c chuy?n h?ng ?n Logon.aspx t? ?ng.
  3. Trong t?p tin Web.config, g? hay dn o?n m? sau.

    M? ny cho php t?t c? ng?i dng truy c?p vo trang Default1.aspx v m?c tin th thoai Subdir1.
    <configuration>
    	<system.web>
    		<authentication mode="Forms" >
    			<forms loginUrl="login.aspx" name=".ASPNETAUTH" protection="None" path="/" timeout="20" >
    			</forms>
    		</authentication>
    <!-- This section denies access to all files in this application except for those that you have not explicitly specified by using another setting. -->
    		<authorization>
    			<deny users="?" /> 
    		</authorization>
    	</system.web>
    <!-- This section gives the unauthenticated user access to the Default1.aspx page only. It is located in the same folder as this configuration file. -->
    		<location path="default1.aspx">
    		<system.web>
    		<authorization>
    			<allow users ="*" />
    		</authorization>
    		</system.web>
    		</location>
    <!-- This section gives the unauthenticated user access to all of the files that are stored in the Subdir1 folder.  -->
    		<location path="subdir1">
    		<system.web>
    		<authorization>
    			<allow users ="*" />
    		</authorization>
    		</system.web>
    		</location>
    </configuration>
    						
    Ng?i dng c th? m? t?p Default1.aspx ho?c b?t k? t?p tin khc ?c lu trong m?c tin th thoai Subdir1 trong ?ng d?ng c?a b?n. H? s? khng ?c chuy?n t? ?ng ?n t?p tin Logon.aspx ? xc th?c.
  4. L?p l?i b?c 3 ? nh?n bi?t b?t k? trang no khc hay m?t m?c tin th thoai m b?n mu?n cho php truy c?p c?a unauthenticated ng?i dng.

THAM KH?O

? bi?t thm chi ti?t, b?m vo s? bi vi?t d?i y ? xem bi vi?t trong c s? ki?n th?c Microsoft:
306590 THNG TIN: ASP.M?ng l?i an ninh t?ng quan
? bi?t thm chi ti?t v? cc t? kha <location>, xem .H?ng d?n c?a nh pht tri?n NET Framework ngy sau Web site c?a Microsoft: </location>
C?u h?nh <location>thi?t ?t</location>

Thu?c tnh

ID c?a bi: 316871 - L?n xem xt sau cng: 14 Thang Sau 2012 - Xem xt l?i: 3.0
p d?ng
  • Microsoft ASP.NET 1.0
  • Microsoft ASP.NET 1.1
T? kha:
kbconfig kbhowtomaster kbsecurity kbweb kbmt KB316871 KbMtvi
My d?ch
QUAN TRONG: Bi vi?t ny ?c d?ch b?ng ph?n m?m d?ch my c?a Microsoft ch? khng ph?i do con ng?i d?ch. Microsoft cung c?p cc bi vi?t do con ng?i d?ch v c? cc bi vi?t do my d?ch ? b?n c th? truy c?p vo t?t c? cc bi vi?t trong C s? Ki?n th?c c?a chng ti b?ng ngn ng? c?a b?n. Tuy nhin, bi vi?t do my d?ch khng ph?i lc no c?ng hon h?o. Lo?i bi vi?t ny c th? ch?a cc sai st v? t? v?ng, c php ho?c ng? php, gi?ng nh m?t ng?i n?c ngoi c th? m?c sai st khi ni ngn ng? c?a b?n. Microsoft khng ch?u trch nhi?m v? b?t k? s? thi?u chnh xc, sai st ho?c thi?t h?i no do vi?c d?ch sai n?i dung ho?c do ho?t ?ng s? d?ng c?a khch hng gy ra. Microsoft c?ng th?ng xuyn c?p nh?t ph?n m?m d?ch my ny.
Nh?p chu?t vo y ? xem b?n ti?ng Anh c?a bi vi?t ny: 316871

Cung cp Phan hi

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com