gpt4 book ai didi

asp.net-mvc - Asp.Net MVC 4 应用程序中的 Signalr

转载 作者:行者123 更新时间:2023-12-01 11:40:41 25 4
gpt4 key购买 nike

我正在开发 Asp.net MVC 应用程序,我想使用信号器。

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

信号器版本:我试过 V1.1.25 and 2.0
有人指导我应该怎么做才能纠正它?

最佳答案

1.写一个集线器扩展集线器

public class MessageHub : Hub

2.检查web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">

关于asp.net-mvc - Asp.Net MVC 4 应用程序中的 Signalr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21040586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com