简体   繁体   中英

DotNetOpenAuth and ReturnToUrl in web forms

I'm using asp.net with url rewrite .

Inside Page Load I have the following code:

OpenIdLogin1.ReturnToUrl = @"~/Login"

When I log in and return to calling page, I get the following error message:

Login failed: The openid.return_to parameter ( http://localhost:12345/Login?dnoa.receiver=ctl00_phContent_ctl00_OpenIdLogin1&dnoa.UsePersistentCookie=Session&dnoa.userSuppliedIdentifier=https://www.google.com/accounts/o8/id ) does not match the actual 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 )

How can I change actual url to virtual url?

Any help would be appreciated.

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

I solved the problem:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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