在开发环境,只能用localhost (本机机器名) 来访问站点,因为在DotNet环境下,
域名的设置不能单单通过设置hosts文件实现,必须在IIS里面配置。
另外:
<casClientConfig
casServerLoginUrl="https://××××.net:8443/cas/login"
casServerUrlPrefix="https://××××.net:8443/cas/"
serverName="http://localhost:1054/CasTest"
如果serverName 配置不当也会导致循环重定向。
在确定
<sessionState mode="StateServer" cookieless="UseCookies" timeout="36000"></sessionState>
配置没有问题的时候,可能因为serverName 的配置问题导致循环重定向。
CasAuthentication.cs
internal static void ProcessRequestAuthentication()
{
HttpContext context = HttpContext.Current;
// Look for a valid FormsAuthenticationTicket encrypted in a cookie.
CasAuthenticationTicket casTicket = null;
FormsAuthenticationTicket formsAuthenticationTicket = GetFormsAuthenticationTicket();
if (formsAuthenticationTicket != null)
{
ICasPrincipal principal;
if (ServiceTicketManager != null)
{
string serviceTicket = formsAuthenticationTicket.UserData;
casTicket = ServiceTicketManager.GetTicket(serviceTicket);
if (casTicket != null)
{
IAssertion assertion = casTicket.Assertion;
if (!ServiceTicketManager.VerifyClientTicket(casTicket))
{
Trace.WriteLine(String.Format("{0}:Ticket failed verification." + Environment.NewLine, CommonUtils.MethodName));
这里是调试的断点设置。