【发布时间】:2015-03-03 12:07:45
【问题描述】:
在将我的 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>
我的 OwinStartup 类在 appsettings 的 web.config 中定义如下:
<add key="owin:AppStartup" value="SignalRStartup, App_Code" />
这就是类的样子:
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);
}
}
还要注意我不能使用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>
我要放弃了,如果你有任何想法,请...
【问题讨论】:
-
如果从配置文件中删除启动属性会发生什么。如果您还使用程序集属性,我认为您不需要这个
-
也是一样,编译的时候挂在'OWinStartup'上找不到(是不是少了一个using指令...
标签: asp.net webforms signalr owin