Convert string to GUID in Actionscript 3 - apache-flex

I'm retrieving an GUID from a webservice with Flex.
With this GUID i have to retrieve an Username from the webservice.
The output gives me a "The key supplied is invalid. It must be of type System.Guid."
I looked everywhere for a solution, but I can't find the right answer.
Anyone?
Thanks!
edited: Is there a way to convert a string to a GUID in AS3?

I don't think you'll need to do this on the client. The problem is that you are sending a string to the server and that it requires an instance of System.Guid there and not a string. You can pass the string to the constructor of System.Guid to create a valid guid from the given string.

Related

Kusto nested json coming as null

I am using Application Insights Log-Explorer query window to visualize the below query.
Inside the field customDimensions.RemotePC I am string a json payload.
When I try to index the stored json via propery-indexing, i get the value as null. I tried to access it as array that turns null as well.
Could you please help me to access the FirstName property in below diagram.
Try this:
| extend todynamic(tostring(rpc)).FirstName
I believe that the issue is that rpc is string (although it looks as json). Thus you need to "cast" it to dynamic. You first need to tell the compiler though that this is a string value.

Entity framework 6 no results

Ive just setup entity framework 6 (for first time) using a model with same fields as db table but im getting 0 results on debug (no errors)
public class footballContext : DbContext
{
public DbSet<football> football { get; set; }
}
and:
var context = new footballContext();
var matches = context.football.Take(20).ToList();
If I view the query its using on "context" I can run it on my database and results are returned fine. I do have entity framework power tools but it only seems to validate the model, is there a way I can test if it can get data or is there something obvious I've missed?
Just found this:
"If you don't specify a connection string or the name of one explicitly, Entity Framework assumes that the connection string name is the same as the class name. The default connection string name in this example would then be SchoolContext, the same as what you're specifying explicitly."
Think I need to start reading up on the naming conventions for this...
For your code to work as it stands, you will need to have a connection string in your web.config called footballContext
If you don't want the connection string to be called that you can create a constructor for your context which calls the base constructor with a specified name.
If you prefer to pass in the connection string explicitly during creation of the context you can again create a constructor for footballContext which accepts a connection string and calls the appropriate base constructor.
See this SO answer for an example.

JSON.Net deserializing from ESB

we receive a JSON string from our ESB that was converted from XML. Since the XML node has no type info, the converted string has data in it like...
"ClientId" : "13579"
The POCO we're deserializing in to has a property...
public int ClientId { get; set; }
Is there any way to tell the deserializer to parse the integer? Preference would be for no annotations in the POCO, and the deserializer should not have direct knowledge of the POCO type.
Thanks!!
Turns out it DOES parse the integer, as Andrew mentioned. The issue was caused by the string having an extra set of "{" "}" surrounding the actual details. These appear to be the result of an XML->JSON conversion happening in the service bus layer. If those are removed, it all seems to be happy :)

Is it possible to use JsonConverter to deserialize an object from a querystring?

I have seen JsonConverter used to deserialize an object from JSON string. Is it possible to deserilize an object from query string? Or, bind query string values to object properties.
My current solution is to build a JSON string from the querystring and then use JsonConverter to convert it.
As of now, you cannot do this. The methods ReadJSON() will only call if it sees that Request is POST and
RequestBody contains a stringified string.

Getting to the query string (GET request array) inside a web service in .NET

I'm looking to find a way to access the .net query string contained in the standard ASP.NET request object inside a web service. In other words if I set a SOAP web service to this url:
http://localhost/service.asmx?id=2
Can I access the ID Get variable?
I just looked for "Request" of the context in asmx file and I saw that. But I'm not sure if it is right.
this.Context.Request.QueryString["id"];
HttpContext.Current.Request.QueryString["id"]
Since you ask, I guess there is no HttpContext.Current.Request ?
While searching for the solution of the same problem i decided to take different approach.
My query string was packed with lots of variables and since I was not able to access query string data from the web service, and I also did not want to send each query string variable as a separate parameter, I prepared my web method to expect one aditional string parameter.
That parameter was window.location (entire url of the page) in my javascript function on .aspx page
Once I had url in my web service, the rest was quite stright forward
Uri myRef = new Uri(stringMyWindowLocationParameter);
System.Collections.Specialized.NameValueCollection mojQuery = HttpUtility.ParseQueryString(myRef.Query);
Now my query string is contained inside myRef object and this is how I call it
// Instead trying to request query string like this
string myId = HttpContext.Current.Request.QueryString["id"];
// ... I called it like this
string myId = myRef["id"];
Maybe it's not the most elegant way but it solved my problem.

Resources