繁体   English   中英

Web表单中的DotNetOpenAuth和ReturnToUrl

[英]DotNetOpenAuth and ReturnToUrl in web forms

我正在使用带有URL rewrite的 asp.net

内部页面加载中,我有以下代码:

OpenIdLogin1.ReturnToUrl = @"~/Login"

登录并返回到调用页面时,出现以下错误消息:

登录失败:openid.return_to参数( http:// localhost:12345 / Login?dnoa.receiver = ctl00_phContent_ctl00_OpenIdLogin1&dnoa.UsePersistentCookie = Session&dnoa.userSuppliedIdentifier = https://www.google.com/accounts/o8/id )不匹配实际网址( 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&id ns = http://specs.openid.net/auth/2.0

如何将实际网址更改为虚拟网址?

任何帮助,将不胜感激。

在对GetResponse的调用中,传递一个HttpRequestInfo对象,该对象使用您希望DotNetOpenAuth视为传入URL的URL进行初始化。

我解决了这个问题:

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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM