'client' is null or not an object in SignalR - signalr

I am successfully running SignalR application on my LocalHost using VS 2010 (4.0 frameWork) And SignalR version 1.1.3 as per following link:
http://www.asp.net/signalr/overview/signalr-1x/getting-started/tutorial-getting-started-with-signalr
But When i deploy this Web Application on my IIS Server:
It throws Javascript Error as
'client' is null or not an object
What should I check..?
TIA

This happens due to not correctly including the dynamic signalr hubs file. In the sample you're reference they are doing:
<script src="/signalr/hubs"></script>
Which is perfectly fine locally. However, if you are to deploy that application to IIS you'd need to ensure that your app is running at the ROOT if you're server.
I'm guessing when you deploy to IIS you're hosting it off of an endpoint like localhost/mysignalrapp/YOUR_STUFF. If that's the case the /signalr/hubs inclusion will not work.
Assuming your html file is at the root if your project try changing the include to:
<script src="signalr/hubs"></script>
This will enable your app to correctly find the signalr endpoint. If you happen to have your HTML file in folders not at the root, adjust the path accordingly.

Do you have a script reference to both the client library and ~/signalR/hubs?

Related

Deploying asp.net web api to azure app service

Problem: after deploying my asp.net core web api to azure app service I can't get a response from the expected endpoint
Steps followed:
I have an api that works fine when serving from my local machine, developed using Visual Studio Code. (The code for that is here https://github.com/samrae7/blog-api FYI)
I followed the instructions in this video: https://www.youtube.com/watch?v=C8J_CRy2_XA to push the files up to Azure App services. Basically I used the VS Code azure app service extension to create a webapp on azure and push my files.
I can see my files have been pushed to Azure ( by logging in to the portal and looking) but when I navigate to the expected URL of my api, http://sams-blog-api.azurewebsites.net, I get 'site not found'. If I try to send a request to the expected endpoint (I append /api/resource as this is the path of the endpoints on my local machine) I get '404 not found'
So my question is what do I have to do to actually get my api up and running online after pushing the files to azure app service
Thanks
Your website is not accessible due to missing DNS entry. I check it using the mxtool
https://mxtoolbox.com/SuperTool.aspx?action=a%3asams-blog-api.azurewebsites.net&run=toolpage#
Please ensure that your url is correct.
The basic answer to this question was that I had not understood that you have to create a Database in azure for your deployed app to connect to, and you need to set the connection string as an env variable in azure so that it knows where to look, and you should also add code that automatically updates the database on launch.
This tutorial was what helped with that: https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-dotnetcore-sqldb
I then hit another issue where the deployed app was still returning a generic 500 server error. By enabling 'Diagnostic logs' via the azure portal, and downloading the logs, I saw this detailed error: The configuration section 'httpProtocol' cannot be read because it is missing a section declaration referring to a piece of config in my Web.config. I deleted it (I don't need it for now) and that fixed the issue

IIS not working with multiple Asp Net MVC apps - Error 404 - React JS

I am having a problem to access my application when I put it inside a website in IIS.
The application works if I publish it as a website. As you can see in the screenshot below, the application is a website. I can access it by just typing the Server IP Address in the browser.
However, I need my server to host multiple applications. This server that I am testing is a copy of another server that hosts multiple asp net applications. The difference is that the applications that this other server hosts are not MVC based. Therefore, I have it working for the old application I have.
I have this new project that I've been developing using ASP Net MVC. My guess is that there is a problem with routing althought I've tried all of these suggestions already:
MVC3 routing not working after deployment on IIS7.5
https://weblog.west-wind.com/posts/2011/Mar/27/ASPNET-Routing-not-working-on-IIS-70
IIS7 MVC Routing Not Working
What is need is something like:
http://ServerIPAddress/Application1
http://ServerIPAddress/Application2
The scenario bellow is what I am aiming for:
Finally, here is the error I am getting. Weird thing is that the website starts to load some things.
UPDATE:
I forgot to mention I am using React JS in my application. I found the problem was related to the router.
Which folder are you choosing while hosting ?
Try selecting project folder which is with .sln file & packages folder.
Well, I am using react Js here, and after some research I found that this problem would be related to the Router.
In order to solve this problem, here is what I did:
1 - In the app.jsx (react uses this file as a router) file I changed:
<Router history={browserHistory}>
to
<Router history={useBasename(() => browserHistory)({ basename: Package.baseName})}>
2 - I referenced my package.json file:
import Package from '../package.json'
3 - Opened my package.json file and added the property baseName:
"baseName":"/nameOfTheFolderInIIS"
After doing that, I was able to connect to my application.
https://localhost:80/nameOfTheFolderInIIS/login

SignalR connection impossible outside vs project

I've set up this ASP VS 2013 project in which I'm using signalR.
This works smoothly. Code of the html file:
<script src="../Scripts/jquery.signalR-2.1.1.js"></script>
<script src="../signalr/hubs"></script>
<script src="SignalR.StockTicker.js"></script>
When debugging this, it is hosted on
http://localhost:50408/SignalR.Sample/StockTicker.html
Now I'm trying to do the same in a Non VS project.
So I've changed the script source :
<script src="imported/jquery.signalR-2.1.1.js"></script>
<script src="http://localhost:50408/signalr/hubs"></script>
<script src="imported/SignalR.StockTicker.js"></script>
But this doesn't work when running. Even after specifying the url in the js code
$.connection.hub.url = 'http://localhost:50408/signalr/hubs';
$.connection.hub.start()
or even without /signalr/hubs
$.connection.hub.url = 'http://localhost:50408/signalr/';
But All I get is a blank screen.
What could be wrong here?
Cheers!
Well you need a web server for processing user requests! SignalR establishes a long-running connection between an user's browser and a web server.
More info
When running the web application in Visual Studio, VS actually starts a web server which hosts your signalR hub. If you're going to deploy your web application, you need a web server. Example.

ASP.Net SignalR: http://127.0.0.1/signalr/hubs (404 Not found) when accessed from different application

I have created a simple chat application following the Getting Started With SignalR URL. When I run and test the program it is working wonderfully fine.
I tried to create a simple client out of this application with a simple HTML and required SignalR.JS package installed as instructed in the second part of Self Hosting SignalR the article where a html and set of JS files try to access the chat application hosted in IIS (one developed following the Getting Started URL.
I am getting the signalr/hubs 404 Not Found error when firebug is used to trace and is not working. Can someone please help me understand what change we need to do to get the chat server working from the JavaScript (and any other) client application.
My chat server is hosted in my IIS as srserver (virtual directory) and the client again is hosted in IIS as srclient (virtual directory) . It is not Cross domain but still not able to get this working.
I had similar problem , that i was missing in the auto generated hubs js (visual studio generates it automatically but when in production environment i had to place it there)
you can generate it using the following command, and than place in the production environment :
signalr ghp /path:[path to the .dll that contains your Hub class]
follow the full instrutinos here

ASP.NET application: AJAX PageMethods returning internal server error about "index.php" on Production Server Only

I have an ASP.NET application running on two almost identical Virtual Windows Server 2003. The first one is my develop and test server. I have installed the .NET WebExtensions for Framework 2.0 there and the application runs well. Now I tried to publish the same application on a second server (lets call him the production server) and also installed the .NET WebExtensions there and compiling and database access runs as well as the complete APS.NET application. Except for calling the static PageMethods through JavaScript AJAX calls. I have used the developer tools of the IE8 to debug into the JavaScript and found that it works identically. Still, all calls of the WebMethods return and internal server error (error code 500) saying "Unknown web method index.php".
Does anybody know what might be wrong with the production server or which configuration need to be changed?
The main difference between the two servers is that the production server uses .NET .../Framework64/v2.0.50727/aspnet_isapi.dll, while the test server uses .../Framework/v2.0.50727/aspnet_isapi.dll.
Some more details:
All PageMethods are static, return a string and have the WebMethod-Attribute.
On both servers the JavaScript creates an XmlHttpRequest object using the resolved URL "http://myDomain/myPage.aspx/myWebMethod" and the "Content-Type"-Header "application/json charset="utf-8" and the bodies contain the correct JSON definition of the parameters for the PageMethods.
Of course all ASPX-pages that use the AJAX PageMethods do have an ASPX-ScriptManager hving the EnablePageMethods-attribute set to "True".
I have solved my problem. There was an ISAPI_ewrite on the production server configured to work globally on all websites. After I have changed that setup to website individual ISAPI_Rewrite for those websites that need to use that rewrite, the AJAX XmlHttpRequests work.

Resources