我正在ASP.NET中設計一個網站,並將Steam API集成到它中。我正在使用DotNetOpenAuth進行身份驗證。我很困惑我如何訪問並顯示變量responseURI
(第22行)。每當我嘗試使用該網頁顯示變量:在ASP.NET網頁上顯示C#變量
<p><%=responseURI%></p>
我得到一個消息,指出:
「responseURI」這個名字不會在當前上下文中。
這裏是我的C#
using DotNetOpenAuth.OpenId.RelyingParty;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class loginPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var openid = new OpenIdRelyingParty();
var response = openid.GetResponse();
if (response != null)
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
// do success
var responseURI = response.ClaimedIdentifier.ToString();
break;
case AuthenticationStatus.Canceled:
case AuthenticationStatus.Failed:
// do fail
break;
}
}
else
{
using (OpenIdRelyingParty openidd = new OpenIdRelyingParty())
{
IAuthenticationRequest request = openidd.CreateRequest("http://steamcommunity.com/openid");
request.RedirectToProvider();
}
}
}
}
的可能的複製[如何調用一個變量在後面的代碼到aspx頁面(https://stackoverflow.com/questions/7406961/how-to-call-a-variable-in-code-behind-to-aspx-page) – NineBerry