2014-03-14 3 views
0

인증을 위해 Azure ACS를 사용하는 사이트가 ADFS에 의해 백업되어 있습니다. 일이 잘 진행되고 사람들이 일을 할 때 그들은 위대하다고 생각되지만 항상 그런 일은 일어나지 않으므로 커스텀 오류 페이지를 구현하고 있습니다. 문제는인증 및 사용자 지정 오류 페이지

, 같은

ID3206: A SignInResponse message may only redirect within the current web application 
Key not valid for use in specified state. 

이러한 오류는 여전히 상관없이 내 Web.config의에서 말하는 추한 노란 오류 화면을 생산하지, 인증 오류를 포착하지 않는 것 같습니다. 그들은 분명히 ASP.NET 오류가 아니라 IIS 오류, 그래서 내 질문은 어디에서 어떻게 web.config에서 페이지를 설정으로 작동하지 않는 '예쁜'방법으로 이러한 오류를 표시하는 사용자 정의 오류 페이지를 넣을 수 있습니까?

수정 : 분명히하기 위해 오류 페이지를 사용하도록 설정하고 다른 오류 페이지로 맞춤 오류를 사용하거나 사용하지 않도록 ACS를 설정했습니다.

답변

0

웹 응용 프로그램의 컨트롤러에서 ACS에서 POST를 허용하고 string 유형의 매개 변수를 사용하는 작업이 필요합니다. 또한 오류에 대한 해당 작업을 가리 키도록 ACS에서 신뢰 당사자 응용 프로그램을 구성해야합니다.

namespace ASPNETSimpleMVC.Controllers 
{ 
public class ErrorController : Controller 
{ 
    // Errors can be mapped to custom strings here. 
    static Dictionary<string, string> ErrorCodeMapping = new Dictionary<string, string>(); 

    static ErrorController() 
    { 
     ErrorCodeMapping["ACS50019"] = "You chose to cancel log-in to the identity provider."; 
     ErrorCodeMapping["ACS60001"] = "No output claims were generated. You may be unauthorized to visit this site."; 
    } 

    // 
    // POST: /Error/ 
    // 
    // If an error occurs during sign-in, ACS will post JSON-encoded errors to this endpoint. 
    // This function displays the error details, mapping specific error codes to custom strings. 
    [AcceptVerbs(HttpVerbs.Post)] 
    public ActionResult Index(string ErrorDetails) 
    { 
     // The error details contain an array of errors with unique error codes to indicate what went wrong. 
     // Additionally, the error details contain a suggested HTTP return code, trace ID, and timestamp, which may be useful for logging purposes. 

     ErrorDetails parsedErrorDetails = new JavaScriptSerializer().Deserialize<ErrorDetails>(ErrorDetails); 

     ViewData["ErrorMessage"] = String.Format("An error occurred during sign-in to {0}. ", parsedErrorDetails.identityProvider); 

     // Loop through all ACS errors, looking for ones that are mapped to custom strings. 
     // When a mapped error is found, stop looking and append the custom string to the error message. 
     foreach (ErrorDetails.Error error in parsedErrorDetails.errors) 
     { 
      if (ErrorCodeMapping.ContainsKey(error.errorCode)) 
      { 
       ViewData["ErrorMessage"] += ErrorCodeMapping[error.errorCode]; 
       break; 
      } 
     } 

     return View("Error"); 
    } 
} 
} 

또한 this article가 도움이 될 수있는 그런 다음 액션 코드에서 당신은 이런 식으로 뭔가를 할 수 있습니다.

관련 문제