IIs错误:应用程序Codebehind ="Global.asax.cs"Inherits ="nadeem.MvcApplication"

omr*_*mri 10 c# asp.net asp.net-mvc-3

我正在尝试部署我的Web项目,并且我一直收到此错误:

Line 1: <%@ Application Codebehind=“Global.asax.cs” Inherits=“nadeem.MvcApplication” Language=“C#” %>
Run Code Online (Sandbox Code Playgroud)

我查看了这篇文章:解析器错误:'/'应用程序中的服务器错误

但它在我的项目中是当前的.

我怀疑它与我的iis7配置有关.

有任何想法吗?

Global.asax中:

<%@ Application Codebehind="Global.asax.cs" Inherits="tamal.pelecard.biz.MvcApplication" Language="C#" %>
Run Code Online (Sandbox Code Playgroud)

的Global.asax.cs:

namespace TamalTest
{
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

public class MvcApplication : HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterGlobalFilters(GlobalFilterCollection filters)
    {
        filters.Add(new HandleErrorAttribute());
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    }
}
Run Code Online (Sandbox Code Playgroud)

}

omr*_*mri 26

解决了,只是重命名了Global.asax或删除它修复了问题:/

我在网上发现的其他已知相关错误:

  1. Global.asax.cs:必须继承自HttpApplication -> public class MvcApplication : HttpApplication
  2. 项目输出必须是bin文件夹而不是Bin/Debug等.
  3. Iss应用程序池的版本不正确.net版本.

  • 2号点将解决问题.它对我有用 (4认同)
  • 谢谢!这正是我所寻找的.我刚刚将项目输出文件夹更改为bin \并再次开始工作! (2认同)

int*_*tox 7

您可以通过编辑Globas.asax文件(而不是Global.asax.cs)来更改它.在Windows资源管理器中的app文件夹中找到它然后编辑

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

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


小智 5

这可能是由于干净的解决方案。bin 中的 dll 将被删除。1.Clean Solution 2.Rebuild the solution 3.如果构建过程失败,并非所有必需的dll都将存储在bin中。这是发生错误的另一种情况