Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIs Error: Application Codebehind=“Global.asax.cs” Inherits=“nadeem.MvcApplication”

I am trying to deploy my web project and I keep getting this error:

Line 1: <%@ Application Codebehind=“Global.asax.cs” Inherits=“nadeem.MvcApplication” Language=“C#” %>

I looked at this post: Parser Error: Server Error in '/' Application

But it is currect in my project.

I suspect it something with my iis7 configuration.

Any ideas?

Global.asax:

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

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}");
    }
}

}

like image 732
omri Avatar asked Jun 01 '14 12:06

omri


2 Answers

Solved, just renamed the Global.asax or delete it fixed the problem :/

Other known related bugs I found on the web:

  1. Global.asax.cs: must inherit from HttpApplication -> public class MvcApplication : HttpApplication
  2. Project output must be the bin folder and not Bin/Debug, etc.
  3. Iss application pool is not in the correct .net version.
like image 55
omri Avatar answered Sep 28 '22 08:09

omri


You can change it by editing Global.asax file (not Global.asax.cs). Find it in app folder in windows explorer then edit

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

to

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

like image 43
intox Avatar answered Sep 28 '22 09:09

intox