"The type or namespace name 'HttpApplication' could not be found" error in .Net6

2.8k views Asked by At

Recently I upgrade my .net 4.8 web project to .net 6. Post upgrade I am getting below error from Global.asax.cs page

public class MvcApplication : HttpApplication

CS0246 The type or namespace name 'HttpApplication' could not be found (are you missing a using directive or an assembly reference?) ~project path\Global.asax.cs

I have tried few possible way to fix this issue, but no luck

It seems like issue is with System.Web namespace in .Net 6. I am getting maximum error because of System.Web namespace

What I can see in .net 6.0 only one class is present in System.Web that is “HttpUtility”. Refer this https://learn.microsoft.com/en-us/dotnet/api/system.web?view=net-6.0

But for System.Web in .Net Framework 4.8 many class was there. Refer this. https://learn.microsoft.com/en-us/dotnet/api/system.web?view=netframework-4.8

Can anyone please help me to understand the issue or any possible way or namespace we can use to fix this

1

There are 1 answers

1
Laurent Gabiot On

It seems you have an ASP.NET application. ASP.NET is a framework that runs under .NET Framework only.

It is not compatible with .NET 6.0 (or any .NET Core and later versions). A new framework replaces ASP.NET for .NET (.NET Core): ASP.NET Core.

ASP.NET Core is a redesign of ASP.NET.

While both framework share some common concepts, they are different frameworks. This page list the differences between the two frameworks.

Some extensive changes might be needed in order to convert an ASP.NET project to an ASP.NET Core project.

As pointed out by @NPras, a migration guide is issued by Microsoft to provide guidance in such a task.