0
我在App_Code文件夾中有GlobalSettings.cs,它爲我的應用程序存儲Session中的各種設置。它在我的WebForm項目中工作正常,我將其複製到MVC5項目用於相同的目的。App_Code中的MVC5類同時存在於兩個臨時目錄中
我將GlobalSettings.cs構建操作設置爲從「內容」「編譯」。否則,我甚至無法編譯MVC項目。
但是當我運行該頁面時,它在我的Layout.cshtml中顯示了這樣的錯誤。它一直說它存在於我的臨時文件夾中。我試圖刪除臨時目錄,清除構建,重建它。但它不起作用。如果我刪除@ ITS.GlobalSettings.RefNo代碼,它可以正常工作,沒有問題。
代碼在App_Code文件\ GlobalSettings.cs
namespace ITS
{
public class GlobalSettings
{
public static string RefNo
{
get
{
return (HttpContext.Current.Session["RefNo"] == null) ? string.Empty : HttpContext.Current.Session["RefNo"].ToString();
}
set
{
HttpContext.Current.Session["RefNo"] = value;
}
}
}
}