locked
HttpRequest RRS feed

  • Question

  • User-1723885661 posted

    Hi

    I'm getting back to .net after a break and I'm working with some legacy code.

    I'm getting an error with HttpContext and a few other lines of code, as it appears later versions of .net Core doesn't have this in System.Web

    Can someone tell me or point me in the right direction of what I need to do to update the code?

    Thanks

    Wednesday, July 8, 2020 9:13 AM

All replies

  • User475983607 posted

    I'm getting back to .net after a break and I'm working with some legacy code.

    I'm getting an error with HttpContext and a few other lines of code, as it appears later versions of .net Core doesn't have this in System.Web

    Can someone tell me or point me in the right direction of what I need to do to update the code?

    Core uses dependency injection.

    https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-context?view=aspnetcore-3.1

    Wednesday, July 8, 2020 1:04 PM
  • User-1723885661 posted

    Thanks, it's been suggested to me that although the code is MVC, it isn't Core.

    Could that be the reason?

    Wednesday, July 8, 2020 1:09 PM
  • User753101303 posted

    You are using Visual Studio? Use "Project", "Properties", "Application" in which you should see which .NET version is targeted. Once knowing what you are using tell as well which error you have and show the line of code on which it happens (seems a compile time error, this is an app you didn't created ?) 

    If you really can't find System.Web.HttpContext.Current my first thought is still that this is a .NET Core application (unless maybe you are confusing web based and desktop apps ?)

    Wednesday, July 8, 2020 1:29 PM
  • User-1723885661 posted

    You are using Visual Studio? Use "Project", "Properties", "Application" in which you should see which .NET version is targeted. Once knowing what you are using tell as well which error you have and show the line of code on which it happens (seems a compile time error, this is an app you didn't created ?) 

    If you really can't find System.Web.HttpContext.Current my first thought is still that this is a .NET Core application (unless maybe you are confusing web based and desktop apps ?)

    The original project doesn't load in Visual Studio, it fails to load whenever i try and use the pre-existing solution file. I've had to import everything into a new project.

    Is there a difference between a web app and a .net core web app?

    This is from the documentation (it was usually VS community edition 2017)

    Fire up VS and create a new C# ASP.NET Web Application project. Choose the MVC
    template for ASP.NET 4.5, and make sure the authentication is set to "Individual User
    Accounts".

    Wednesday, July 8, 2020 1:36 PM
  • User475983607 posted

    Lee Martin

    Is there a difference between a web app and a .net core web app?

    Yes, there is a huge difference. between ASP.NET Core and ASP.NET.

    As far as I can tell you are building an ASP.NET project which has nothing to do with Core.  Are you trying to load an existing project in Visual Studio 2017?  What kind of project?  Web Forms?  MVC? Classic ASP?

    Wednesday, July 8, 2020 2:38 PM
  • User-1723885661 posted

    It's looking like that was the issue. I should have opened it with ASP.Net not ASP.Net core

    Wednesday, July 8, 2020 2:48 PM
  • User475983607 posted

    It's looking like that was the issue. I should have opened it with ASP.Net not ASP.Net core

    Let's start over.  ASP.NET Core is the latest framework.  Visual Studio 2019 is the better editor for Core.  If all you're doing is opening an existing project then Visual Studio will use the project type in the project file. 

    Wednesday, July 8, 2020 3:46 PM
  • User-1723885661 posted

    Lee Martin

    It's looking like that was the issue. I should have opened it with ASP.Net not ASP.Net core

    Let's start over.  ASP.NET Core is the latest framework.  Visual Studio 2019 is the better editor for Core.  If all you're doing is opening an existing project then Visual Studio will use the project type in the project file. 

    Lets start over again....

    As stated above, the existing project does not load in visual studio.

    The problem has been resolved now, thank you all for your help.

    Wednesday, July 8, 2020 3:50 PM