简体   繁体   English

System.Web可以与带有完整框架的ASP.Net Core一起使用

[英]Can System.Web be used with ASP.Net Core with Full Framework

We are running serveral sites based on different .Net versions. 我们基于不同的.Net版本运行多个站点。

One of the sites is running .Net 4.6 and ASP.Net MVC 5.xx 其中一个站点运行.Net 4.6和ASP.Net MVC 5.xx

To use the new syntax for Razor we want to upgrade this site to use .Net 4.6 and ASP.Net Core 要使用Razor的新语法,我们希望将此站点升级为使用.Net 4.6和ASP.Net Core

We use FormsAuthentication on our sites, and we will continue using that so user can move between sites. 我们在我们的网站上使用FormsAuthentication,我们将继续使用它,以便用户可以在网站之间移动。 (one of the sites is a SharePoint site running FormsAuthentication) (其中一个站点是运行FormsAuthentication的SharePoint站点)

We understand that ASP.Net Core is not using anything from System.Web but we need to use that from controllers (to create FormsAuthentication cookie during login) and from HttpModule to verify cookie. 我们知道ASP.Net Core没有使用System.Web中的任何东西,但是我们需要使用来自控制器(在登录时创建FormsAuthentication cookie)和HttpModule来验证cookie。

I have not been able to find any example how to use system.web from a site running ASP.Net Core with Full framwork. 我无法找到如何使用完整框架运行ASP.Net Core的站点中的system.web的任何示例。 I have not been able to add dependency for system.web in project.json. 我无法在project.json中为system.web添加依赖项。

Questions. 问题。

  1. Is it possible to use system.web from a setup like this? 是否可以从这样的设置中使用system.web?

  2. How can we add dependency to system.web so System.Web.FormsAuthentication is available from ASP.NET MVC 6. (Controllers/ http module) 我们如何向system.web添加依赖项,以便ASP.NET MVC 6中提供System.Web.FormsAuthentication。(Controllers / http模块)

That may not work the way you think. 这可能不像你想象的那样有效。 When you use .Net Core MVC against the full framework it's true that the System.Web namespace exists and could technically be called but it won't work like you want. 当您对完整框架使用.Net Core MVC时,System.Web命名空间确实存在并且可以在技术上被调用,但它不会像您想要的那样工作。 The reason is that the request pipeline for Asp.Net Core and System.Web are totally different. 原因是Asp.Net Core和System.Web的请求管道完全不同。 So for example when using Asp.Net Core MVC if you check the HttpContext object from when a request comes in it will be populated with all the information you expect but if you check for the current request using System.Web objects you will see that their is no current request. 因此,例如当使用Asp.Net Core MVC时,如果从请求进入时检查HttpContext对象,它将填充您期望的所有信息,但如果使用System.Web对象检查当前请求,您将看到他们的目前没有要求。 That's because the current request didn't come in via the System.Web pipeline. 那是因为当前请求没有通过System.Web管道进入。 It came in through the .Net Core "pipeline" if you will. 如果你愿意,它会通过.Net Core“管道”进入。 So if you are using .Net Core MVC you will need to stick with the tools and approaches of that framework, not the ones provided in System.Web. 因此,如果您使用.Net Core MVC,您将需要坚持使用该框架的工具和方法,而不是System.Web中提供的工具和方法。

However, It should be possible to reference the System.Web.dll if your really want to. 但是,如果你真的想要,应该可以引用System.Web.dll。 If you are using VS2015 you will need to get a copy of the System.Web.Dll and wrap it in a nuget package in order to establish a reference to it. 如果您使用的是VS2015,则需要获取System.Web.Dll的副本并将其包装在nuget包中以便建立对它的引用。 See here .net core 1.0 visual studio referencing external dll VS2017RC has alpha tooling that should eliminate the need to wrap it in a NuGet package but I've had trouble installing it on my machine so I can't vouch for it personally. 请参阅此处.net core 1.0 visual studio引用外部DLL VS2017RC具有alpha工具,可以消除将其包装在NuGet包中的需要,但是我在我的机器上安装它时遇到了麻烦,因此我无法亲自担保。 Update: VS2017 now has great tooling for Asp.Net Core and referencing full framework Dlls. 更新: VS2017现在为Asp.Net Core提供了很好的工具,并引用了完整的框架Dll。

Using the System.Web dll isn't the same as using System.Web. 使用System.Web dll与使用System.Web不同。 None of the System.Web pipeline will run for your ASP.NET Core application so you can't do what you are trying to do. System.Web管道都不会为您的ASP.NET Core应用程序运行,因此您无法执行您尝试执行的操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Request.Url.AbsoluteUri在ASP.NET Core 2.0中不起作用(使用System.Web) - Request.Url.AbsoluteUri not working in asp.net core 2.0 (Using System.Web) ASP.NET 中缺少“System.web”引用 - Missing “System.web” reference in ASP.NET ASP.NET Core TypeLoadException无法从程序集“ System.Web”加载类型“ System.Web.PreApplicationStartMethodAttribute” - ASP.NET Core TypeLoadException Could not load type 'System.Web.PreApplicationStartMethodAttribute' from assembly 'System.Web' 可以在Kestrel上自托管剃刀Web应用程序的.NET Core应用程序可以在完整的.NET和参考system.web上运行吗? - Can a .NET Core app, self hosting razor web app on Kestrel, run on full .NET and reference system.web? <system.web> .net核心中的全球化 - <system.web> globalization in .net core 我的ASP.NET Web应用程序中web.config文件的system.web部分中的调试参数 - Debug parameter in system.web part of the web.config file in my ASP.NET web application ASP.NET 5 Web api模板,未解析的参考System.Web - ASP.NET 5 Web api template, unresolved reference System.Web ASP.NET MVC 5 web.config <system.web> 编译和httpRuntime错误 - ASP.NET MVC 5 web.config <system.web> compilation & httpRuntime error ASP.NET Core Web Application(.NET Framework)项目模板缺少System.Web.MVC dll - ASP.NET Core Web Application (.NET Framework) project template is missing System.Web.MVC dll AdWords SDK 在 .net 核心应用程序中查找 System.Web 参考 - AdWords SDK looks for System.Web reference in .net core app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM