jun*_*nta 2 asp.net webforms cors signalr owin
将我的asp.net webform网站从Owin 2.1.0升级到Owin 3.0.1之后,我有前面提到的编译错误......我正在尝试使用SignalR 2和CORS.这是我的packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="jQuery" version="2.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.Core" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.JS" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.AspNet.SignalR.SystemWeb" version="2.2.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Cors" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
</packages>
Run Code Online (Sandbox Code Playgroud)
我的OwinStartup类在appsettings中的web.config中定义如下:
<add key="owin:AppStartup" value="SignalRStartup, App_Code" />
Run Code Online (Sandbox Code Playgroud)
这就是班级的样子:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Owin;
using Microsoft.Owin;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Cors;
using System.IO;
[assembly: OwinStartup(typeof(SignalRStartup))]
public class SignalRStartup
{
public void Configuration(IAppBuilder app)
{
// Enable detailed errors (remember to remove it
var hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
//hubConfiguration.EnableCrossDomain = true;
app.UseCors(CorsOptions.AllowAll);
app.MapSignalR(hubConfiguration);
}
}
Run Code Online (Sandbox Code Playgroud)
还要注意我不能用app.Map("/signalr", map => { ... });......
编辑:我在我的web.config中找到了那些在升级之前我没有的行:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="3.0.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Cors" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
如果你有任何想法我就要放弃了.
好极了 !找到了 !非常感谢这篇文章: 找不到类型或命名空间IAppBuilder(缺少使用指令作为程序集引用).
我的问题通过重新安装Microsoft.owin解决,如ИвоНедев建议:
PM> Update-Package Microsoft.Owin -Reinstall
Removing 'Microsoft.Owin 3.0.1' from ww.
Value does not fall within the expected range.
Successfully removed 'Microsoft.Owin 3.0.1' from ww.
Removing 'Owin 1.0' from ww.
Successfully removed 'Owin 1.0' from ww.
Uninstalling 'Microsoft.Owin 3.0.1'.
Successfully uninstalled 'Microsoft.Owin 3.0.1'.
Uninstalling 'Owin 1.0'.
Successfully uninstalled 'Owin 1.0'.
Attempting to resolve dependency 'Owin (? 1.0)'.
Installing 'Owin 1.0'.
Successfully installed 'Owin 1.0'.
Installing 'Microsoft.Owin 3.0.1'.
You are downloading Microsoft.Owin from Microsoft, the license agreement to which is available at http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Owin 3.0.1'.
Adding 'Owin 1.0' to ww.
Successfully added 'Owin 1.0' to ww.
Adding 'Microsoft.Owin 3.0.1' to ww.
Successfully added 'Microsoft.Owin 3.0.1' to ww.
Run Code Online (Sandbox Code Playgroud)
我的脑袋现在可以止血了:-P
| 归档时间: |
|
| 查看次数: |
6228 次 |
| 最近记录: |