“ASP.global_asax does not exist in the namespace ASP”

后端 未结 9 2266
梦毁少年i
梦毁少年i 2020-12-23 08:56

I created a RazorFunctions.cshtml file on App_Code

@functions {
    public static string GetActiveClassIf(string controllerName, string actionName = null)
           


        
9条回答
  •  情深已故
    2020-12-23 09:52

    I had the same issue.

    I manually edited the generated file file.cshtml.72cecc2a.cs (it was at AppData\Local\Temp\Temporary ASP.NET Files\root) and changed ASP.global_asax to System.Web.HttpApplication and the error went away.

    This is the generated code:

    protected static ASP.global_asax ApplicationInstance {
        get {
            return ((ASP.global_asax)(Context.ApplicationInstance));
        }
    }
    

    I changed it to:

    protected static System.Web.HttpApplication ApplicationInstance {
        get {
            return ((System.Web.HttpApplication)(Context.ApplicationInstance));
        }
    }
    

    I don't know why this is happening though.

提交回复
热议问题