" ASP.global_asax不命名空间中的ASP&QUOT存在; [英] "ASP.global_asax does not exist in the namespace ASP"

查看:623
本文介绍了" ASP.global_asax不命名空间中的ASP&QUOT存在;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了APP_ code一个RazorFunctions.cshtml文件

I created a RazorFunctions.cshtml file on App_Code

@functions {
    public static string GetActiveClassIf(string controllerName, string actionName = null)
    {
        var routeData = @HttpContext.Current.Request.RequestContext.RouteData;
        string currentController = routeData.Values["controller"].ToString();
        string currentAction = routeData.Values["action"].ToString();
        return controllerName == currentController &&
            (String.IsNullOrEmpty(actionName) || currentAction == actionName) ? "active" : "";
    }
}

当我编译,它给了我2个错误(编译没有取得成功的问题和现场工作),但错误是烦人。

and when I compile, it give me 2 errors (compilation get success and site work without problem) but the errors are annoying.

该RazorFunctions.cshtml作为内容(试过编译但不当然CSHTML文件的工作)

The RazorFunctions.cshtml are as Content (tried compile but doesn't work with cshtml files of course)

的Global.asax.cs是:

Global.asax.cs is :

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        ModelMetadataConfig.RegisterModelMetadata();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        Database.SetInitializer(new MigrateDatabaseToLatestVersion<ApplicationDbContext, Configuration>());
        //Database.SetInitializer(new DropCreateDatabaseAlways<ApplicationDbContext>());
    }
}

<%@ Application Codebehind="Global.asax.cs" Inherits="Bouron.Web.MvcApplication" Language="C#" %>

这是我第一次使用APP_ code,所以我不知道自己还能做什么,所有的搜索返回ASP.NET 1-2的结果,是过时的,其中剃须刀甚至不存在,所以我不知道我怎么能解决这个问题。

This is the first time I use the App_Code so I don't know what else to do, all search returns ASP.NET 1-2 results, are out of date where razor doesn't even exist so I'm not sure how can I solve this.

我在使用Visual Studio 2015年(以防万一它事项)

I'm using Visual Studio 2015 (just in case it matters)

推荐答案

在进一步调查之后,我发现这是一个已知的问题。

After further investigation I found that this is a known issue.

来源:<一个href=\"https://support.microsoft.com/en-us/kb/3025133\">https://support.microsoft.com/en-us/kb/3025133

ASP.NET和Web开发

ASP.NET and Web Development


  • 当您创建一个Web窗体4.5 WAP,并打开一个Web窗体页,您将收到错误列表窗口中的以下错误:

  • When you create a Web Forms 4.5 WAP and open a Web Form page, you receive the following errors in the Errors List window:

该项目将没有任何问题运行。错误CS0234类型或命名空间名称'global_asax'不命名空间中的ASP存在(是否缺少程序集引用?)
错误CS0234类型或命名空间名称'的Linq'不存在命名空间'系统'存在(是否缺少程序集引用?)
假设你在Visual Studio 2015年RC使用C#和VB新的语言功能。当您使用C#或VB在Web窗体页或剃刀视图,您会收到运行时错误。

The project will run without any issues. Error CS0234 The type or namespace name 'global_asax' does not exist in the namespace 'ASP' (are you missing an assembly reference?) Error CS0234 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) Assume that you use new language features for C# and VB in Visual Studio 2015 RC. You receive a runtime error when you use C# or VB in a Web Form page or in Razor Views.

要解决此问题,安装Microsoft。codeDom.Providers.DotNetCompilerPlatform的NuGet包。该软件包将取代基于罗斯林提供商的收件箱codeDOM提供商ASP.NET。

To work around this issue, install Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package. This package will substitute the Roslyn-based provider for the in-box CodeDom providers for ASP.NET.

这篇关于&QUOT; ASP.global_asax不命名空间中的ASP&QUOT存在;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆