Search Results

Search found 2 results on 1 pages for 'polonskyg'.

Page 1/1 | 1 

  • SignalR cannot read property client of undefined

    - by polonskyg
    I'm trying to add SignalR to my project (ASPNET MVC 4). But I can't make it work. In the below image you can see the error I'm receiving. I've read a lot of stackoverflow posts but none of them is resolving my issue. This is what I did so far: 1) Ran Install-Package Microsoft.AspNet.SignalR -Pre 2) Added RouteTable.Routes.MapHubs(); in Global.asax.cs Application_Start() 3) If I go to http://localhost:9096/Gdp.IServer.Web/signalr/hubs I can see the file content 4) Added <modules runAllManagedModulesForAllRequests="true"/> to Web.Config 5) Created folder Hubs in the root of the MVC application 6) Moved jquery and signalR scripts to /Scripts/lib folder (I'm not using jquery 1.6.4, I'm using the latest) This is my Index.cshtml <h2>List of Messages</h2> <div class="container"> <input type="text" id="message" /> <input type="button" id="sendmessage" value="Send" /> <input type="hidden" id="displayname" /> <ul id="discussion"> </ul> </div> @section pageScripts { <!--Reference the SignalR library. --> <script src="@Url.Content("~/Scripts/jquery.signalR-1.0.0-rc1.min.js")" type="text/javascript"></script> <!--Reference the autogenerated SignalR hub script. --> <script type="text/javascript" src="~/signalr/hubs"></script> <script src="@Url.Content("~/Scripts/map.js")" type="text/javascript"></script> } This is my IServerHub.cs file (located inside Hubs folder) namespace Gdp.IServer.Ui.Web.Hubs { using Microsoft.AspNet.SignalR.Hubs; [HubName("iServerHub")] public class IServerHub : Hub { public void Send(string name, string message) { Clients.All.broadcastMessage(name, message); } } } And this is map.js $(function () { // Declare a proxy to reference the hub. var clientServerHub = $.connection.iServerHub; // Create a function that the hub can call to broadcast messages. clientServerHub.client.broadcastMessage = function (name, message) { $('#discussion').append('<li><strong>' + name + '</strong>:&nbsp;&nbsp;' + message + '</li>'); }; // Get the user name and store it to prepend to messages. $('#displayname').val(prompt('Enter your name:', '')); // Set initial focus to message input box. $('#message').focus(); // Start the connection. $.connection.hub.start().done(function () { $('#sendmessage').click(function () { // Html encode display name and message. var encodedName = $('<div />').text($('#displayname').val()).html(); var encodedMsg = $('<div />').text($('#message').val()).html(); // Call the Send method on the hub. clientServerHub.server.send(encodedName, encodedMsg); // Clear text box and reset focus for next comment. $('#message').val('').focus(); }); }); }); The DLL's I see references for SignalR are: Microsoft.AspNet.SignalR.Core Microsoft.AspNet.SignalR.Owin Microsoft.AspNet.SignalR.SystemWeb Any ideas how to get it work? Should I make any change because the scripts are in /Script/lib folder? NOTE I'm following the instruction found here on how to set up Windsor Castle to make it work with SignalR, and again, seems that the proxy cannot be created and I'm getting the same error: Cannot read property client of undefined meaning that the proxy to the hub was not created This is how I have it in the server public class IncidentServerHub : Hub and like this in the client var clientServerHub = $.connection.incidentServerHub; Again, I can see the dynamically created file here: /GdpSoftware.Server.Web/signalr/hubs So, Why the proxy is not created? Thanks in advance!!! Guillermo.

    Read the article

  • jqgrid retrieving empty rows using webapi (REST)

    - by polonskyg
    I'm using jqgrid in an ASPNET MVC4 project with WebApi (REST), Entity Framework 5 using Unit Of Work and Repository patterns. My problem is that I see the data flowing as json to the browser and I see three rows in the grid, but those rows are empty, and the data is not shown (three empty rows in the grid). This is method to get the data in the WebApi controller: public dynamic GetGridData(int rows, int page, string sidx, string sord) { var pageSize = rows; var index = sidx; var order = sord; var categories = Uow.Categories.GetAll().OrderBy(t => (string.IsNullOrEmpty(index) ? "Id" : index) + " " + (order ?? "desc")); var pageIndex = Convert.ToInt32(page) - 1; var totalRecords = categories.Count(); var totalPages = (int)Math.Ceiling((float) totalRecords / (float) pageSize); var categoriesPage = categories.Skip(pageIndex * pageSize).Take(pageSize).ToList(); return new { total = totalPages, page = page, records = totalRecords, rows = (from category in categoriesPage select new { id = category.Id.ToString(), cell = new string[] { category.Id.ToString(), category.Name, category.Description } }).ToArray() }; } This is the json received in the browser { "total": 1, "page": 1, "records": 3, "rows": [{ "id": "1", "cell": ["1", "Category 1", null] }, { "id": "3", "cell": ["3", "Category 3", "asAS"] }, { "id": "4", "cell": ["4", "Category 4", null] }] } This is the .js file with jqgrid jQuery("#ajaxGrid").jqGrid({ url: $("#ServiceUrl").val(), datatype: "json", jsonReader: { repeatitems: false, id: "Id" }, colNames: ['Id', 'Name', 'Description'], colModel: [ { name: 'id', editable: true, sortable: true, hidden: true, align: 'left' }, { name: 'name', editable: true, sortable: true, hidden: false, align: 'left' }, { name: 'description', editable: true, sortable: true, hidden: false, align: 'left' } ], mtype: 'GET', rowNum: 15, pager: '#ajaxGridPager', rowList: [10, 20, 50, 100], caption: 'List of Categories', imgpath: $("#ServiceImagesUrl").val(), altRows: true, shrinkToFit: true, viewrecords: true, autowidth: true, height: 'auto', error: function(x, e) { alert(x.readyState + " "+ x.status +" "+ e.msg); } }); function updateDialog(action) { return { url: $("#ServiceUrl").val(), closeAfterAdd: true, closeAfterEdit: true, afterShowForm: function (formId) { }, modal: true, onclickSubmit: function (params) { var list = $("#ajaxGrid"); var selectedRow = list.getGridParam("selrow"); params.url += "/" + list.getRowData(selectedRow).Id; params.mtype = action; }, width: "300", ajaxEditOptions: { contentType: "application/json" }, serializeEditData: function (data) { delete data.oper; return JSON.stringify(data); } }; } jQuery("#ajaxGrid").jqGrid( 'navGrid', '#ajaxGridPager', { add: true, edit: true, del: true, search: false, refresh: false }, updateDialog('PUT'), updateDialog('POST'), updateDialog('DELETE') ); BTW, If I want to return jqGridData instead the dynamic, How should I do it? Did is showing empty rows as well: public class jqGridData<T> where T : class { public int page { get; set; } public int records { get; set; } public IEnumerable<T> rows { get; set; } public decimal total { get; set; } } public jqGridData<Category> GetGridData(int rows, int page, string sidx, string sord) { var pageSize = rows; var index = sidx; var order = sord; var categories = Uow.Categories.GetAll().OrderBy(t => (string.IsNullOrEmpty(index) ? "Id" : index) + " " + (order ?? "desc")); var pageIndex = Convert.ToInt32(page) - 1; var totalRecords = categories.Count(); var totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize); var categoriesPage = categories.Skip(pageIndex * pageSize).Take(pageSize); return new jqGridData<Category> { page = page, records = totalRecords, total = totalPages, rows = categoriesPage }; }

    Read the article

1