Can System.Web be used with a fully structured ASP.Net kernel?

We use server sites based on different versions of .Net.

One of the sites is running .Net 4.6 and ASP.Net MVC 5.xx

To use the new syntax for Razor, we want to update this site to use .Net 4.6 and ASP.Net Core

We use FormsAuthentication on our sites, and we will continue to use this so that the user can navigate between sites. (one of the sites is a SharePoint site running FormsAuthentication).

We understand that ASP.Net Core does not use anything from System.Web, but we must use this from the controllers (to create a FormsAuthentication cookie during login) and from the HttpModule to check the cookie.

I could not find any example of using system.web from a site running ASP.Net Core with a full wireframe design. I was unable to add a dependency for system.web in project.json.

Questions.

  • Is it possible to use system.web from such an installation?

  • How to add a dependency on system.web so that System.Web.FormsAuthentication can be obtained in ASP.NET MVC 6. (Controllers / http module)

+6
source share
2 answers

Using dll System.Web does not match using System.Web. None of the System.Web pipelines will run for your ASP.NET Core application, so you cannot do what you are trying to do.

+3
source

Perhaps this is not what you think. When you use .Net Core MVC against a complete framework, it is true that the System.Web namespace exists and can be technically invoked, but it will not work the way you want. The reason is that the query pipeline for Asp.Net Core and System.Web is completely different. For example, when using Asp.Net Core MVC, if you check the HttpContext object from the moment the request arrives, it will be filled with all the information you expect, but if you check the current request using System.Web objects, you will see that they are not current request. This is because the current request did not come through the System.Web pipeline. He walked in through the .Net Core pipeline, if you like. Therefore, if you use .Net Core MVC, you will need to adhere to the tools and approaches to this structure, and not those presented in System.Web.

However, it should be possible to reference System.Web.dll if you really want to. If you are using VS2015, you will need to get a copy of System.Web.Dll and wrap it in a nuget package to establish a link to it. See .net core 1.0 visual studio linking to an external dll VS2017RC here has an alpha toolkit that should eliminate the need to wrap it in the NuGet package, but I had problems installing it my car, so I can not vouch for it personally.

+4
source

Source: https://habr.com/ru/post/1012809/


All Articles