共用方式為


使用 CAPTCHA 顯示控件驗證 CAPTCHA 挑戰字串

使用 CAPTCHA 顯示控制件來產生 CAPTCHA 挑戰字串,然後要求使用者輸入他們看到或聽到的內容來驗證它。 若要顯示 CAPTCHA 顯示控制項,您可以從自我判斷技術配置文件參考它 ,而且您必須將自我判斷技術配置檔setting.enableCaptchaChallenge 元數據值設定為 true

這個螢幕快照顯示註冊頁面上顯示的 CAPTCHA 顯示控制器:

Screenshot of CAPTCHA as it appears in the sign-up page.

註冊頁面會使用 CAPTCHA 顯示控件載入。 然後,用戶會輸入他們看到或聽到的字元。 [ 傳送驗證碼] 按鈕會將驗證碼 傳送給使用者的電子郵件,而且不是 CAPTCHA 顯示控件元素,但它會導致驗證 CAPTCHA 挑戰字串。

CAPTCHA 顯示控件元素

下表摘要說明 CAPTCHA 顯示控制項所包含的專案。

元素 必要 描述
UserInterfaceControlType Yes 值必須是 CaptchaControl
InputClaims Yes 需要一或多個宣告做為輸入,以指定 CAPTCHA 挑戰類型,並唯一識別挑戰。
DisplayClaims Yes 要向用戶顯示的宣告,例如 CAPTCHA 挑戰程式代碼,或從使用者收集,例如使用者輸入的程式代碼
OutputClaim No 在使用者完成 CAPTCHA 程式代碼驗證程序之後,要傳回至自我判斷提示頁面的任何宣告。
動作 Yes CAPTCHA 顯示控件包含兩個動作: GetChallengeVerifyChallenge
GetChallenge 動作會產生,然後在使用者介面上顯示 CAPTCHA 挑戰程式代碼。
VerifyChallenge 動作會驗證使用者輸入的 CAPTCHA 挑戰代碼。

下列 XML 代碼段代碼顯示 CaptchaProvider 顯示控制器的範例:

<DisplayControls>
    ...
    <DisplayControl Id="captchaControlChallengeCode" UserInterfaceControlType="CaptchaControl" DisplayName="Help us beat the bots">
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="challengeType" />
        <InputClaim ClaimTypeReferenceId="challengeId" />
      </InputClaims>
    
      <DisplayClaims>
        <DisplayClaim ClaimTypeReferenceId="challengeType" ControlClaimType="ChallengeType" />
        <DisplayClaim ClaimTypeReferenceId="challengeId" ControlClaimType="ChallengeId" />
        <DisplayClaim ClaimTypeReferenceId="challengeString" ControlClaimType="ChallengeString" />
        <DisplayClaim ClaimTypeReferenceId="captchaEntered" ControlClaimType="CaptchaEntered" />
      </DisplayClaims>
    
      <Actions>
        <Action Id="GetChallenge">
          <ValidationClaimsExchange>
            <ValidationClaimsExchangeTechnicalProfile
              TechnicalProfileReferenceId="HIP-GetChallenge" />
          </ValidationClaimsExchange>
        </Action>
    
        <Action Id="VerifyChallenge">
          <ValidationClaimsExchange>
            <ValidationClaimsExchangeTechnicalProfile
              TechnicalProfileReferenceId="HIP-VerifyChallenge" />
          </ValidationClaimsExchange>
        </Action>
      </Actions>
    </DisplayControl>
    ...
</DisplayControls>

下一步