Unable to get value of the property 'transports' - SignalR - signalr

I'm using signalr in my asp.net web forms application, all seems to work good, except that I'm getting exception on the line
$.connection.hub.start();
However, if I click no on "Do you want to Debug" popup, signalr functionality works pretty well. The full error message is this
Unable to get value of the property 'transports': object is null or undefined
And here is complete js code
var docStatusUpdate = $.connection.docstatus;
docStatusUpdate.statusUpdate = function (msg, session) {
var sessionId = $('input#sessionValue').val();
if (sessionId == session) {
$("#statusUpdateMsgContainer").text(msg);
}
};
docStatusUpdate.endProcessing = function (session) {
var sessionId = $('input#sessionValue').val();
if (sessionId == session) {
$('input[id*=btnRefresh]').click();
}
};
$.connection.hub.start();
function assignValues() {}
I'm using Asp.net 4.0, signalr is installed via nuget.
Any ideas how can I solve this ?

I had a discussion on http://jabbr.net regarding to this issue, and it turned out, that none of the suggestions work. The main thing was to make sure that jQuery library isn't referenced more than once. Anyways, I just deleted browser data, and it started to work as expected.

Related

Why is Meteor session variables getting cleared on page refresh

I just noticed in my meteor app that the session variables are getting cleared on page refresh. So
How is meteor saving user login details ?
Are they not saved in session ?
How can this issue be managed ?
Meteor.Session is only for the client-side. It's a JavaScript global object in your application. If you refresh the page it's wiped out. Your session is stored in client-side localStorage, https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage. Meteor does not use cookies for Session, https://www.meteor.com/blog/2014/03/14/session-cookies.
You would need to explain more what you are trying to accomplish. I use Meteor.Session once the page is loaded, and not for many things, but to get my initial state of things, my URLs contain enough info to set initial state.
With Meteor you ideally do not want to refresh the browser. Everything happens or should happen with AJAX and HTML5 push state ideally and Meteor's reactiveness.
You should read their documentation. Here's the section on Session, http://docs.meteor.com/#session
This is an old question, but since I found myself needing the same thing, here's how I did it. I 'extended' the session to actually store it on the localstorage when setting a value, and loading up the localstorage into the session when the page loads.
// improving the session package to persist it to the localstorage
Session._set = Session.set;
Session.set = function(key,value) {
Session._set(key,value);
localStorage.setItem(key,JSON.stringify(value));
};
// helper function
function isJSON(str) {
try {
return (JSON.parse(str) && !!str);
} catch (e) {
return false;
}
}
// loading the localstorate on load
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
var value = localStorage.getItem(key);
Session._set(key,isJSON(value) ? JSON.parse(value) : value);
}

Session doesn't work in IE, it works in all other browsers

I'm developing a website with asp.net, visual studio 2012, IIS8, .Net Framework 4.
I use SESSIONS to store user information after login.
when user click sign in button, I send information to .ashx file like this:
var url = "SignIn.ashx?username=" + UserName.value + "&password=" + PassWord.value;
xmlRequest_SignIn.open("GET", url);
xmlRequest_SignIn.onreadystatechange = function () { ApplyUpdateSignIn() }
xmlRequest_SignIn.send(null);
SignIn.ashx:
... // check login information and then
HttpContext.Current.Session["UserName"] = username.toString();
...
Now in every page of my website, I check this session to authenticate the user in ajax:
var url = "CheckMemberAccount.ashx";
xmlRequest_member.open("GET", url);
xmlRequest_member.onreadystatechange = function () { ApplyUpdateGetMemberAccount() }
xmlRequest_member.send(null);
CheckMemberAccount.ashx:
if (Convert.ToString(HttpContext.Current.Session["UserName"]) == "" || null == HttpContext.Current.Session["UserName"])
{
// user not logged in
}
else
{
// user logged in
}
For log out I use ajax too:
var url = "SignOut.ashx";
xmlRequest_SignOut.open(GET, url);
xmlRequest_SignOut.onreadystatechange = function () { ApplyUpdateSignOut() }
xmlRequest_SignOut.send(null);
SignOut.ashx:
// I try everything to make the session null or invalid!
// BUT it doesn't take effect in Internet Explorer !!
HttpContext.Current.Session["UserName"] = "";
HttpContext.Current.Session["UserName"] = null;
HttpContext.Current.Session.Clear();
HttpContext.Current.Session.RemoveAll();
HttpContext.Current.Session.Abandon();
HttpContext.Current.Request.Cookies["ASP.NET_SessionId"].Value = "";
As you can see I've tried everything to make session null or invalid.
This code works well in all browsers(Chrome, FireFox, Safari, Opera, Netscape, ...) EXCEPT in Internet Explorer !
In IE after Signing out, when I check the member acount with CheckMemberAccount.ashx file, the session still remain valid with valid value as if no sign out happened !
This problem is only in IE !!
note that IE settings are all in their defaults.
I have tried Global.asax:
After adding the class, and without adding any code to it ( just keep it unchanged with it's default functions such as Session_Start() ), My problem changed and now I always get null for the session in CheckMemberAccount.ashx ! and again the problem is just in IE !
I didn't find any solution after 3 days.
I'll appreciate any help :)
I believe the checkmemberaccount call is being cached in the browser by iE. this has gotten me in trouble many times before. Add a random variable to your Ajax call and I believe your problem will be solved.
You can verify this by using a tool like fiddler. You should see that the browser is caching the GET request. You could also switch from a GET to a POST. POSTS are not cached by IE.
By the way... You should fix this for any get requests that you don't want to cache.

asp.net app calling service says its not initialized?

So this code runs in an asp.net app on Linux. The code calls one of my services. (WCF doesn't work on mono currently, that is why I'm using asmx). This code works AS INTENDED when running from Windows (while debugging). As soon as I deploy to Linux, it stops working. I'm definitely baffled. I've tested the service thoroughly and the service is fine.
Here is the code producing an error: (NewVisitor is a void function taking 3 strings in)
//This does not work.
try
{
var client = new Service1SoapClient();
var results = client.NewVisitor(Request.UserHostAddress, Request.UrlReferrer == null ? String.Empty : Request.UrlReferrer.ToString(), Request.UserAgent);
Logger.Debug("Result of client: " + results);
}
Here is the error generated: Object reference not set to an instance of an object
Here is the code that works perfectly:
//This works (from the service)
[WebMethod(CacheDuration = _cacheTime, Description = "Returns a List of Dates", MessageName = "GetDates")]
public List<MySqlDateTime> GetDates()
{
return db.GetDates();
}
//Here is the code for the method above
var client = new Service1Soap12Client();
var dbDates = client.GetDates();
I'd love to figure out why it is saying that the object is not set.
Methods tried:
new soap client.
new soap client with binding and endpoint address specified
Used channel factory to create and open the channel.
If more info is needed I can give more. I'm out of ideas.
It looks like a bug in mono. You should file a bug with a reproducible test case so it can be fixed (and possibly find a workaround you can use).
Unfortunately, I don't have Linux to test it but I'd suggest you put the client variable in an using() statement:
using(var client = new Service1SoapClient())
{
var results = client.NewVisitor(Request.UserHostAddress, Request.UrlReferrer == null ?
String.Empty : Request.UrlReferrer.ToString(), Request.UserAgent);
Logger.Debug("Result of client: " + results);
}
I hope it helps.
RC.

Microsoft Speech Recognition in webservices is not returning the result

Well i'm using Microsoft Speech Platform SDK 10.2.
I made a asp.Net WebService application and most of the WebServices works fine (HelloWorld(), etc...), but I have one service that uses the SpeechRecognitionEngine and when I deploy the application and try to run this webservice I get no result, i.e, I can see through the debug mode that it reaches the return line, but when I call it trought the browser the page keeps loading for ever, without any response.
Here's a sample of the code:
[WebMethod]
public bool voiceRecognition() {
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("pt-PT"));
Choices c = new Choices();
c.Add("test");
GrammarBuilder gb = new GrammarBuilder();
gb.Append(c);
Grammar g = new Grammar(gb);
sre.LoadGrammar(g);
sre.InitialSilenceTimeout = TimeSpan.FromSeconds(5);
//// just for Testing
RecognitionResult result = null;
if (result != null) {
return true;
} else {
return false;
}
}
Note: I'm using IIS to deploy the WebService Application.
If someone have some thoughts please let me know.
I don't know if you've found your answer or not. When trying to solve this myself a couple of days ago, I stumbled across your question and it matched our circumstances to a "T".
In order to fix it all we had to do was put...
sre.RecognizeAsyncStop();
sre.Dispose();
where "sre" is your SpeechRecognitionEngine variable. If you don't stop it and dispose of it at the end of your web service then the web service won't return.
Hope this helps. :)

Is it possible to find the function and/or line number that caused an error in ActionScript 3.0 without using debug mode?

I'm currently trying to implement an automated bug reporter for a Flex application, and would like to return error messages to a server along with the function/line number that caused the error. Essentially, I'm trying to get the getStackTrace() information without going into debug mode, because most users of the app aren't likely to have the debug version of flash player.
My current method is using the UncaughtErrorEvent handler to catch errors that occur within the app, but the error message only returns the type of error that has occurred, and not the location (which means it's useless). I have tried implementing getStackTrace() myself using a function name-grabber such as
private function getFunctionName (callee:Function, parent:Object):String {
for each ( var m:XML in describeType(parent)..method) {
if ( this[m.#name] == callee) return m.#name;
}
return "private function!";
}
but that will only work because of arguments.callee, and so won't go through multiple levels of function calls (it would never get above my error event listener).
So! Anyone have any ideas on how to get informative error messages through the global
error event handler?
EDIT: There seems to be some misunderstanding. I'm explicitly avoiding getStackTrace() because it returns 'null' when not in debug mode. Any solution that uses this function is what I'm specifically trying to avoid.
Just noticed the part about "I don't want to use debug." Well, that's not an option, as the non-debug version of Flash does not have any concept of a stack trace at all. Sucks, don't it?
Not relevant but still cool.
The rest is just for with the debug player.
This is part of my personal debug class (strangely enough, it is added to every single project I work on). It returns a String which represents the index in the stack passed -- class and method name. Once you have those, line number is trivial.
/**
* Returns the function name of whatever called this function (and whatever called that)...
*/
public static function getCaller( index:int = 0 ):String
{
try
{
throw new Error('pass');
}
catch (e:Error)
{
var arr:Array = String(e.getStackTrace()).split("\t");
var value:String = arr[3 + index];
// This pattern matches a standard function.
var re:RegExp = /^at (.*?)\/(.*?)\(\)/ ;
var owner:Array = re.exec(value);
try
{
var cref:Array = owner[1].split('::');
return cref[ 1 ] + "." + owner[2];
}
catch( e:Error )
{
try
{
re = /^at (.*?)\(\)/; // constructor.
owner = re.exec(value);
var tmp:Array = owner[1].split('::');
var cName:String = tmp.join('.');
return cName;
}
catch( error:Error )
{
}
}
}
return "No caller could be found.";
}
As a side note: this is not set up properly to handle an event model -- sometimes events present themselves as either not having callers or as some very weird alternate syntax.
You don't have to throw an error to get the stack trace.
var myError:Error = new Error();
var theStack:String = myError.getStackTrace();
good reference on the Error class
[EDIT]
Nope after reading my own reference getStackTrace() is only available in debug versions of the flash player.
So it looks like you are stuck with what you are doing now.

Resources