【发布时间】:2014-01-10 18:34:45
【问题描述】:
我正在开发 Asp.net MVC 应用程序,我想使用 signalr。
Signalr 托管在 IIS 中。
我添加了信号器 dll 并添加了对它的引用。
在 Global.asax 中,
我把代码,
在Application_Start()
中 " RouteTable.Routes.MapHubs();"
我已经粘贴了 Global.asax,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
RouteTable.Routes.MapHubs();
}
}
当我运行应用程序时,比如说"http://localhost:4432",
当我尝试"http://localhost:4432/signalr/hubs" 时,我得到如下异常,
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /signalr/hubs
Signalr 版本:我试过V1.1.25 and 2.0
有人指导我应该怎么做才能纠正它?
【问题讨论】:
-
您使用的是什么版本的 SignalR?
-
我也想问同样的问题,请分享您的 signalR 版本。那里有大量“如何开始使用 signalR”教程,请寻找与您使用相同版本的教程。
-
@SoonDead 我试过了,版本 1.1.25 和版本 2.0...
-
您尝试将
using Microsoft.AspNet.SignalR;添加到您的命名空间吗? -
@Tim B James In Global.asax?
标签: asp.net-mvc asp.net-mvc-4 signalr signalr-hub signalr.client