Aspnetcore.docs: Migrate Asp.net 4.6 Application to ASP.Net Core

Created on 10 May 2018  Â·  8Comments  Â·  Source: dotnet/AspNetCore.Docs

I need documentation to Migrate Asp.net 4.6 Application to ASP.Net Core . Please let me know if you have any information for it.

Thanks.

Regards,
Joyal


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P4 Source - Docs.ms

Most helpful comment

@joyalsttl Unfortunately, there's no tooling available to automatically migrate an ASP.NET 4.x project to ASP.NET Core. It's a very manual process.

Off the top of my head, below is a checklist of tasks and considerations. As with anything else, there are other things to consider as well.

  • [ ] Decide which target framework you'll use for your ASP.NET Core project: .NET Framework or .NET Core. As of ASP.NET Core 2.0, a minimum of .NET Framework 4.6.1 is required. If you choose to target .NET Core instead, you should target a minimum of .NET Core 2.0 to gain the best compatibility with your existing code. Read more here.
  • [ ] Decide which IDE / editor you'll use for your code. If using Visual Studio, VS 2017 is recommended. Visual Studio Code can also be used on Windows, macOS, and Linux. The C# extension is required if using Visual Studio Code. If using a Mac, Visual Studio for Mac can be used.
  • [ ] Install the .NET Portability Analyzer extension. It allows you to select the framework(s) to which you plan to migrate. Based on those selections, it flags incompatibilities that you need to address.
  • [ ] [Web Forms](https://docs.microsoft.com/aspnet/web-forms/), Web Hooks, Web Pages, and VB.NET aren't supported in ASP.NET Core. Because VB.NET isn't supported, _*.vbhtml_ files aren't supported either. SignalR is supported as of ASP.NET Core 2.1. MVC and Web API have been supported since the first release of ASP.NET Core; although, Web API is now technically known as MVC (there was a consolidation effort). Read more about app model and language support here.
  • [ ] NuGet has changed, such that the packages.config file has been replaced with <PackageReference /> nodes in the _.csproj_ file. NuGet isn't capable of installing static files in the new project system. For that reason, you'll need to either use a CDN or consider a different package manager (npm, Yarn, LibMan, etc.) for installing client-side libraries and frameworks (e.g., Bootstrap, Angular, jQuery). The *repositories.config file you would've had for your solution can be deleted.
  • [ ] ASP.NET Core uses a completely new project system. Open the *.csproj file, and you'll notice that the project's folders and files are no longer listed there. Also, the mess of GUIDs and NuGet package hint paths have disappeared.
  • [ ] For hosting your ASP.NET Core app on Windows with IIS, a reverse proxy is recommended. IIS forwards requests over to Kestrel for processing. Read more here. It's also possible to host the app with Nginx, Apache, Docker, and most cloud service providers.
  • [ ] By default, static assets such as fonts, HTML, CSS, and JavaScript files are served from the project's _wwwroot_ folder. Consider moving such files to that folder, or you can configure ASP.NET Core's static files middleware to look elsewhere for these files. Read more here.
  • [ ] The _web.config_ transforms used in ASP.NET 4.x projects aren't supported in ASP.NET Core. Additionally, the _web.config_ file's <appSettings /> node is no longer used. Such config values should now be placed in an appsettings.json file at the project root. You can configure ASP.NET Core to read from XML config files instead, but that's not the default. Read more here.

While this checklist may seem daunting, the benefits of migrating are significant. As you read through the migration docs, please feel free to ask more questions. We're here to help make your migration a success.

All 8 comments

@joyalsttl The migration docs for this type of app are here: https://docs.microsoft.com/aspnet/core/migration/proper-to-2x/. Is there something you're trying to do that isn't documented there?

@scottaddie,
Actually, The am not able to add "Microsoft.AspNetCore.All" via nuget package. I got the below error.

Error Could not install package 'Microsoft.AspNetCore.All 2.1.0-rc1-final'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Please let me know to resolve this issue.

Thanks.

Migration does not work like that. You have to create a new web project and move your code over. There is a walkthrough in doing this with an mvc sample

@isaac2004 ,

Thanks for the reply. I understood now that the migration will not be done automatically. But, I have to copy folders and files manually. But, the problem is that, My project is written in Classic ASP.Net 4.6.1. I want to migrate that to ASP.Net Core. Please let me know for that.

Thanks.

@joyalsttl Unfortunately, there's no tooling available to automatically migrate an ASP.NET 4.x project to ASP.NET Core. It's a very manual process.

Off the top of my head, below is a checklist of tasks and considerations. As with anything else, there are other things to consider as well.

  • [ ] Decide which target framework you'll use for your ASP.NET Core project: .NET Framework or .NET Core. As of ASP.NET Core 2.0, a minimum of .NET Framework 4.6.1 is required. If you choose to target .NET Core instead, you should target a minimum of .NET Core 2.0 to gain the best compatibility with your existing code. Read more here.
  • [ ] Decide which IDE / editor you'll use for your code. If using Visual Studio, VS 2017 is recommended. Visual Studio Code can also be used on Windows, macOS, and Linux. The C# extension is required if using Visual Studio Code. If using a Mac, Visual Studio for Mac can be used.
  • [ ] Install the .NET Portability Analyzer extension. It allows you to select the framework(s) to which you plan to migrate. Based on those selections, it flags incompatibilities that you need to address.
  • [ ] [Web Forms](https://docs.microsoft.com/aspnet/web-forms/), Web Hooks, Web Pages, and VB.NET aren't supported in ASP.NET Core. Because VB.NET isn't supported, _*.vbhtml_ files aren't supported either. SignalR is supported as of ASP.NET Core 2.1. MVC and Web API have been supported since the first release of ASP.NET Core; although, Web API is now technically known as MVC (there was a consolidation effort). Read more about app model and language support here.
  • [ ] NuGet has changed, such that the packages.config file has been replaced with <PackageReference /> nodes in the _.csproj_ file. NuGet isn't capable of installing static files in the new project system. For that reason, you'll need to either use a CDN or consider a different package manager (npm, Yarn, LibMan, etc.) for installing client-side libraries and frameworks (e.g., Bootstrap, Angular, jQuery). The *repositories.config file you would've had for your solution can be deleted.
  • [ ] ASP.NET Core uses a completely new project system. Open the *.csproj file, and you'll notice that the project's folders and files are no longer listed there. Also, the mess of GUIDs and NuGet package hint paths have disappeared.
  • [ ] For hosting your ASP.NET Core app on Windows with IIS, a reverse proxy is recommended. IIS forwards requests over to Kestrel for processing. Read more here. It's also possible to host the app with Nginx, Apache, Docker, and most cloud service providers.
  • [ ] By default, static assets such as fonts, HTML, CSS, and JavaScript files are served from the project's _wwwroot_ folder. Consider moving such files to that folder, or you can configure ASP.NET Core's static files middleware to look elsewhere for these files. Read more here.
  • [ ] The _web.config_ transforms used in ASP.NET 4.x projects aren't supported in ASP.NET Core. Additionally, the _web.config_ file's <appSettings /> node is no longer used. Such config values should now be placed in an appsettings.json file at the project root. You can configure ASP.NET Core to read from XML config files instead, but that's not the default. Read more here.

While this checklist may seem daunting, the benefits of migrating are significant. As you read through the migration docs, please feel free to ask more questions. We're here to help make your migration a success.

@scottaddie,
I understood that there is no tool which automatically transfer my Classic ASP.net 4.6.1 application to ASP.Net core.

In fact, I want to get benefit of Cross Platform, I want to migrate it. I don't think that ASP.Net core will work if i will copy all the files manually from "Classic ASP.Net 4.6.1" to ASP.Net core.

I am again repeating that my application has been built using "Classic ASP.Net 4.6.1" using WEB FORMS.

Please let me know if you can share docs of migration for it.

Thanks.

@joyalsttl Web Forms is not supported in ASP.NET Core, as documented here. I recommend migrating from ASP.NET 4.x Web Forms to ASP.NET 4.x MVC first. Web Forms and MVC can exist in the same ASP.NET 4.x project, so you can migrate one ASPX file at a time to minimize impact. Once you've completed that migration, you can begin the migration to ASP.NET Core MVC using the instructions we have documented. To be honest, there's a lot significant amount of work ahead of you.

After porting ASP.NET 4.x to ASP.NET Core 2.2, does anyone know how Razor view files (CSHTML) are compiled? That's the only part I'm stuck on.

https://stackoverflow.com/questions/58667252/is-it-possible-to-use-asp-net-core-2-x-mvc-on-net-framework-4-6-1-console-appli

Was this page helpful?
0 / 5 - 0 ratings