如何使用ASP.NET 4.0设置ChatJS?

时间:2014-05-08 10:17:49

标签: signalr asp.net-4.0 chatjs

我只想用asp.net 4.0设置ChatJs。我阅读了随其提供的所有步骤的文档。但我无法安装到我的应用程序中。

这里是用4.0框架构建的web应用程序。所以这个chatjs可能支持更高版本的4.5。是否有任何机构知道如何使用带有sql server 2008的asp.net 4.0安装此聊天应用程序。 我成功地将所有基本文件(如chatjs和signalR)设置到我的Web应用程序中,但是在startup.cs文件中出现了一些编译时错误。

这是我的startup.cs文件代码:

using ChatJs.Admin;
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(Startup))]
namespace ChatJs.Admin
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            this.ConfigureAuth(app);
            app.MapSignalR();
        }
    }
}

这是我的编译时错误:

Error   1   'ChatJs.Admin.Startup' does not contain a definition for 'ConfigureAuth' and no extension method 'ConfigureAuth' accepting a first argument of type 'ChatJs.Admin.Startup' could be found (are you missing a using directive or an assembly reference?) F:\EasyWeb\App_Code\Startup.cs  11  18  F:\EasyWeb\

Error   2   'Owin.IAppBuilder' does not contain a definition for 'MapSignalR' and no extension method 'MapSignalR' accepting a first argument of type 'Owin.IAppBuilder' could be found (are you missing a using directive or an assembly reference?)   F:\EasyWeb\App_Code\Startup.cs  12  17  F:\EasyWeb\

请帮帮我..

1 个答案:

答案 0 :(得分:2)

关于ConfigureAuth方法的缺席:

您正在参考此电话:

https://github.com/ChatJS/ChatJs-Demo/blob/master/ChatJs.Admin/Startup.cs#L17

它显然缺失的原因是因为Microsoft确定将所有ASP.NET启动代码放在App_Start文件夹中的最佳位置,因此在那里有一个Startup的部分类。 ConfigureAuth方法在这里:

https://github.com/ChatJS/ChatJs-Demo/blob/master/ChatJs.Admin/App_Start/Startup.Auth.cs#L11

关于MapSignalR方法的缺席:

MapSignalR方法在OwinExtensions程序集的类Microsoft.AspNet.SignalR.Core中定义。这是SignalR特有的,它只能在.NET 4.5上运行。

在.NET Framework 4.0中运行ChatJS 2.0

ChatJS 2.0将在.NET 4.0上运行,但只有在你引用SignalR 1而不是2时才会运行。没有理由说ChatJS使用SignalR 2 appart作为最新版本。请注意,Microsoft更改了SignalR从版本1初始化为2的方式,因此本教程的SignalR部分将不适用。