微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么我不能在我的代码asp.net c#中使用app_code中的代码文件

我正在开发一个asp.net网络应用程序,我的app_code中有几个类,但由于某种原因,我不能在我的代码中使用它们中的任何一个.我尝试使用相同的命名空间,我尝试在两个文件中没有任何命名空间,但没有任何帮助.

这是我的页面代码

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

知道可能是什么问题吗?
提前致谢

解决方法

进入文件属性,并将Build Action更改为Compile

原文地址:https://www.jb51.cc/aspnet/248276.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐