[英]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.