我已将 CS 文件移出App_Data
文件夹,因为重复构建时出现错误,一个在编译时构建,一个在运行时构建,所以我被告知将它们移出该文件夹。
两个文件,Default.aspx.cs
namespace CrystalTech
{
public partial class newVersion_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
LoginInitialiser loginData = new LoginInitialiser();
loginData.loadData();
}
}
}
和 Security.cs
namespace CrystalTech
{
// Handles all our login logic
public class LoginInitialiser
{
public bool isLoggedIn { get; private set; }
public LoginInitialiser()
{
this.isLoggedIn = false;
}
// Fetches the users data
public void loadData()
{
if (HttpContext.Current.Session["loggedIn"] != null)
{
this.isLoggedIn = (bool)HttpContext.Current.Session["loggedIn"];
}
// Fetch the data if we are logged in
if (this.isLoggedIn)
{
}
// Otherwise redirect
else
{
HttpContext.Current.Response.Redirect("../logins/index.asp?action=dn&r=" + CommonFunctions.GetCurrentPageName());
}
}
}
// Holds users information
public class User
{
public int ID { get; private set; }
public string username { get; private set; }
public Company company { get; private set; }
public string title { get; private set; }
public string forenames { get; private set; }
public string surnames { get; private set; }
public string email { get; private set; }
}
// Holds company information
public class Company
{
public int ID { get; private set; }
public string name { get; private set; }
public string telephone { get; private set; }
}
}
为什么 Default.aspx.cs 会抛出:
找不到类型或命名空间名称“LoginInitialiser”(您是否缺少 using 指令或程序集引用?)