我使用SignalR Visual studio 2013创建了一个简单的聊天应用程序(但该应用程序在2012年),框架4.5。
我只使用ASP.NET Web表单(不是MVC)
当我通过视觉工作室运行时,它就起作用了。但当我在IIS中配置它时,它在页面控制台中给出了以下错误-
GET http://localhost/chat/signalr/hubs 404 (Not Found) localhost/:30
Uncaught TypeError: Cannot read property 'client' of undefined localhost/chat/:112
"chat"是虚拟目录的名称。
添加了以下内容。以及web.config-中
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
代码来自Global.asax.cs-
protected void Application_Start(object sender, EventArgs e)
{
// Register the default hubs route: ~/signalr/hubs
RouteTable.Routes.MapHubs();
}
来自Index.Html-的代码
<!--Reference the SignalR library. -->
<script src="Scripts/jquery.signalR-1.0.0.js"></script>
<!--Reference the autogenerated SignalR hub script. -->
<script src="signalr/hubs"></script>
我也尝试过,但没有成功-
<script src="<%= ResolveUrl("~/signalr/hubs") %>" type="text/javascript"></script>
注意-我指的是http://www.codeproject.com/Articles/562023/Asp-Net-SignalR-Chat-Room提前谢谢。
如果您在Visual Studio中运行它,您可能会在版本8中使用IIS Express。SignalR使用的web套接字在IIS 7.x上不完全受支持,因此您必须使用Windows 8或Server 2012。当然,您可以在开发过程中使用IIS Express 8。
我遇到了确切的问题,在我安装IIS 7.5无扩展支持修补程序
您可以尝试使用websocket作为传输层吗
var connection=$.hubConnection('http://'+window.location.host);var proxy=connection.createHubProxy('chatHub');
connection.start({transport:['webSockets']}).done(function(){});