我正在研究一個asp.net web應用程序,並且我的app_code中有幾個類,但出於某種原因,我無法使用任何他們在我的代碼中。我嘗試使用相同的命名空間,我試圖在兩個文件中沒有任何命名空間,但沒有任何幫助。爲什麼我不能在我的代碼中使用app_code中的代碼文件asp.net c#
這是我的網頁代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LinkedIn;
using LinkedIn.ServiceEntities;
namespace Authentication
{
public partial class LinkedinMoreInfo : LinkedinBasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
而且我的代碼中的類:
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using LinkedIn;
namespace Authorisation
{
public class LinkedInBasePage : System.Web.UI.Page
{
private string AccessToken
{
get { return (string)Session["AccessToken"]; }
set { Session["AccessToken"] = value; }
}
private InMemoryTokenManager TokenManager
{
get
{
var tokenManager = (InMemoryTokenManager)Application["TokenManager"];
if (tokenManager == null)
{
string consumerKey = ConfigurationManager.AppSettings["LinkedInConsumerKey"];
string consumerSecret = ConfigurationManager.AppSettings["LinkedInConsumerSecret"];
if (string.IsNullOrEmpty(consumerKey) == false)
{
tokenManager = new InMemoryTokenManager(consumerKey, consumerSecret);
Application["TokenManager"] = tokenManager;
}
}
return tokenManager;
}
}
protected WebOAuthAuthorization Authorization
{
get;
private set;
}
protected override void OnLoad(EventArgs e)
{
this.Authorization = new WebOAuthAuthorization(this.TokenManager, this.AccessToken);
if (!IsPostBack)
{
string accessToken = this.Authorization.CompleteAuthorize();
if (accessToken != null)
{
this.AccessToken = accessToken;
Response.Redirect(Request.Path);
}
if (AccessToken == null)
{
this.Authorization.BeginAuthorize();
}
}
base.OnLoad(e);
}
}
}
任何想法可能是什麼問題? 在此先感謝
你會得到什麼錯誤? – ChrisF
'Authentication'和'Authorisation'是否是「相同的命名空間」? – mellamokb
您是否確定App_Code包含在項目中?如果將類從App_Code移動到項目的根目錄,它是否工作? – James