2013-07-25 30 views
3

我一直在使用SignalR創建簡單的聊天應用程序時,Visual Studio 2013(但應用程序是在2012年),框架4.5。SignalR聊天在IIS7配置不工作時 - Windows 7的

我使用ASP.NET的WebForms只(不MVC)

它,當我通過Visual Studio的運行工作。 但是,當我在IIS中配置它,它給在網頁控制檯下面的錯誤 -

GET http://localhost/chat/signalr/hubs 404 (Not Found) localhost/:30 
Uncaught TypeError: Cannot read property 'client' of undefined localhost/chat/:112 

「聊天」是虛擬目錄的名稱。

新增FOLL。以及在web.config中 - 從Global.asax.cs-

<system.webServer> 
    <validation validateIntegratedModeConfiguration="false"/> 
    <modules runAllManagedModulesForAllRequests="true"/> 
</system.webServer> 

代碼

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> 

注 - 我a米提到這個http://www.codeproject.com/Articles/562023/Asp-Net-SignalR-Chat-Room 在此先感謝。

+0

我已經嘗試從以下鏈接的每個解決方案 - https://github.com/SignalR/SignalR/wiki/Faq – Abhi

+0

可能的重複:http://stackoverflow.com/questions/17237037/signalr-fails-on-iis – slfan

回答

0

如果您在Visual Studio中,你可能在8版本中使用IIS快速運行SignalR使用網絡套接字這是不完全支持IIS 7.x的,所以你必須使用Windows 8或Server 2012的當然你在開發過程中可以使用IIS Express 8。

+0

你是說我必須安裝IIS8嗎?我使用的IIS7不是7.5 – Abhi

+0

正確的,你要麼使用Windows 8或Server 2012的 – slfan

+0

http://stackoverflow.com/questions/11601561/signalr-w-web-sockets –

0

我有完全相同的問題,這是固定後,我安裝了IIS 7.5擴展名的詢問服務hotfix

+0

當然,SignalR會工作,但它不會使用WebSockets,因爲Windows 7不會支持WebSockets。 SignalR將使用回退機制。有關詳細信息,請參閱此博客文章https://blogs.msdn.microsoft.com/timlee/2013/03/21/hosting-a-signalr-application-on-windows-2008r2-and-iis-7-5/ – slfan

0

,你可以嘗試使用的WebSocket作爲傳輸層

VAR連接= $ .hubConnection( 'http://'+ window.location.host); var proxy = connection.createHubProxy('chatHub');

connection.start({運輸:[ '的WebSockets']})。DONE(函數(){});