代码之家  ›  专栏  ›  技术社区  ›  Å¡ljaker

web窗体中的DotNetOpenAuth和ReturnToUrl

  •  1
  • Å¡ljaker  · 技术社区  · 16 年前

    我在用 asp.net 静态化 .

    页面加载

    OpenIdLogin1.ReturnToUrl = @"~/Login"
    

    当我登录并返回到调用页时,会收到以下错误消息:

    http://localhost:12345/Login?dnoa.receiver=ctl00_phContent_ctl00_OpenIdLogin1&dnoa.UsePersistentCookie=Session&dnoa.userSuppliedIdentifier=https://www.google.com/accounts/o8/id )与实际URL不匹配( http://localhost:12345/Templates/Pages/Login/Login.aspx?dnoa.receiver=ctl00_phContent_ctl00_OpenIdLogin1&dnoa.UsePersistentCookie=Session&dnoa.userSuppliedIdentifier=https://www.google.com/accounts/o8/id&openid.ns=http://specs.openid.net/auth/2.0

    如何将实际url更改为虚拟url?

    任何帮助都将不胜感激。

    2 回复  |  直到 16 年前
        1
  •  3
  •   Andrew Arnott    16 年前

    在你的电话里 GetResponse ,传入 HttpRequestInfo 对象,用希望DotNetOpenAuth将其视为传入URL的URL进行初始化。

        2
  •  2
  •   Å¡ljaker    16 年前

    我解决了这个问题:

    var openId = new OpenIdRelyingParty();
    HttpContext httpContext = HttpContext.Current;
    
    var headers = new WebHeaderCollection();
    foreach (string header in httpContext.Request.Headers)
    {
        headers.Add(header, httpContext.Request.Headers[header]);
    }
    
    string requestUrl = string.Format("http://localhost:12345/Login/{0}",
                                       httpContext.Request.Url.Query);
    
    var requestInfo = new HttpRequestInfo(httpContext.Request.HttpMethod,
                                            new Uri(requestUrl),
                                            httpContext.Request.RawUrl, headers,
                                            httpContext.Request.InputStream);
    
    var response = openId.GetResponse(requestInfo);
    
    推荐文章