本文介绍了Global.asax中找不到code-behind类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到这个错误,当我尝试运行我继承了一个Web应用程序。这是写在2010年的C#3.5和使用的mvc 2.我已经安装了,但是我得到这个错误的必要的库。

I keep getting this error when I try to run a web app that I have inherited. It was written in 2010 for C# 3.5 and uses Mvc 2. I have installed the necessary libraries however I get this error.

错误1未能加载类型
  AdminConsole.MvcApplication。 C:\\路径\\为\\我的\\ APP \\ Global.asax中1

的Global.asax.cs如下:

Global.asax.cs looks like this:

using System.Web.Mvc;
using System.Web.Routing;

namespace AdminConsole
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}.aspx/{action}/{id}", // URL with parameters
                new { controller = "Entitlement", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}

和Global.asax中是这样的:<%@应用继承=AdminConsole.MvcApplicationLANGUAGE =C#%>

And Global.asax looks like this: <%@ Application Inherits="AdminConsole.MvcApplication" Language="C#" %>

推荐答案

添加 codebehind =的Global.asax.cs标记文件(Global.asax中):

Add Codebehind="Global.asax.cs" to the Markup file (Global.asax):

发件人:

<%@ Application Inherits="AdminConsole.MvcApplication" Language="C#" %>

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

这篇关于Global.asax中找不到code-behind类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 06:27