.NET Programming

133K

Solutions

38K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

Share tech news, updates, or what's on your mind.

Sign up to Post

I'm writing a C# .Net function that reads a Json message sent as part of a HttpRequest. The HttpRequestMessage includes the Json message as in an encoded format and as a parameter as follows (for example):
url%3Dhttp%3A%2F%2Fwww.somewebsite.com%2Fsomepage%26page_name%3Dsomepagename%26%26data.json%3D%7B%22time_submitted%22%3A%5B%2209%3A51+PM+UTC%22%5D%2C%22emailaddress%22%3A%5B%22someoneemail%40yahoo.com%22%5D%2C%22device%22%3A%5B%22desktop%22%5D%2C%22page_uuid%22%3A%5B%22ac272d63-abcd-4d38-8ee6-5d36875ea098%22%5D%2C%22fc_referrer%22%3A%5B%22%28not+set%29%22%5D%7D

The problem I have is how to read and decode the Json data in my C# function (the function is running in Azure).

My code starts like this:

using System.Net;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)

{

    string jsonContent = await req.Content.ReadAsStringAsync(); //This works fine and reads the encoded Json message
   
     JObject o = JObject.Parse(jsonContent); // This comes back with error: Newtonsoft.Json: Unexpected character encountered while parsing value: p. Path '', line 0, position 0.


If I test using a decoded httpsrequestmessage, everything works fine. However, with the encoded Json value, I can't read the data. The encoded Json data is sent from another system so I have no control to …
0
Cloud Class® Course: SQL Server Core 2016
LVL 12
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

a c# solution has multiple projects with a .nuget project/folder as well. Inside it is the executable NuGet.exe.
what is the purpose of this executable and I see this executable is checked into the source code repository too.

does this executable , download the latest packages or packages needed for the project, like we run a command "nuget get package " in visual studio.
why do we need the executable though , for this?
0
I am integrating into a webservice, it returns json, here are 2 types of results from it
{"numFound":1,"QTime":77,"attributions":"http://www.gisgraphy.com/attributions.html","result":[{"id":100004730,"lng":36.710459425750635,"lat":-1.336961662155654,"streetName":"Marula Lane","city":"Bulbul","state":"Kajiado","countryCode":"KE","geocodingLevel":"STREET","distance":300.4280656229352,"adm1Name":"Kajiado","formatedFull":"Marula Lane, Bulbul, Kajiado, Kenya","formatedPostal":"Marula Lane, Bulbul","speedMode":"OSM","maxSpeed":"30 mph","azimuthStart":267,"azimuthEnd":251,"length":1161.411457366,"sourceId":33136013}]}



{"numFound":1,"QTime":2537,"attributions":"http://www.gisgraphy.com/attributions.html","result":[{"id":22523950,"lng":36.81669998168945,"lat":-1.2833000421524048,"zipCode":"09831","city":"APO AE","countryCode":"US","geocodingLevel":"CITY","distance":13413.984061400277,"formatedFull":"APO AE,  (09831), United States","formatedPostal":"APO AE, 09831"}]}

Open in new window


I've used the visual studio paste special as JSON class on the first result as that seems to have more info
I'm using the 2nd result as the  test scenario

I then use this code
Result json1 = JsonConvert.DeserializeObject<Result>(jResult);

Open in new window


But all the objects are empty or null

What am I doing wrong?
0
I have the following c# code(all variables are doubles)

 if (Latitude == lastLocation.Latitude && Longitude == lastLocation.Longitude)
                    {

Open in new window


This just compares exact numbers, what i need to do is Compare latitude and longitude to see if in 10 meters of previous location
This code runs 100 times a second, so i need it to be super fast too

I'm not sure how to achieve this so would appreciate some code help
0
I want to update all the forms in my application to a particular setting.  Here is my code:

  • Dim list As New StringBuilder
  • Dim allForms() As Form = (From t As Type In Me.GetType().Assembly.GetTypes()
  •                                  Where t.BaseType Is GetType(Form)
  •                                  Let f = DirectCast(Activator.CreateInstance(t), Form)
  •                                  Select f).ToArray
  •        For Each x In allForms
  •            If x.AutoScaleMode = AutoScaleMode.Dpi Then
  •                'do nothing
  •            Else
  •                list.Append(x.Name & vbCrLf)
  •                x.AutoScaleMode = AutoScaleMode.Dpi
  •            End If
  •        Next
  •        Dim a As String = list.ToString
  •        MsgBox(a)

It's not updating in the form.  What do I need to do?
0
I keep getting a "Object reference not set to an instance of an object." error when trying to access an OData api. Code can be found at http://apps.wsifb.com/TestApp2.zip
0
Hi,
I am getting an error :
Memory out / Invalid parameter exception when I run this code :
dtnew : Datatable

I am trying to export my images to powerpoint.

  If IsDBNull(dtnew.Rows(i).Item(3)) = False Then

                            Dim pictureData As Byte() = dtnew.Rows(i).Item(3)

                            'Create a stream in memory containing the bytes that comprise the image.
                            Using stream As New IO.MemoryStream(pictureData, True)
                                stream.Position = 0
                                'Read the stream and create an Image object from the data.
                                picture = New Bitmap(stream)
                            End Using


                            oldbitmap = New Bitmap(picture)




                            ppApp.Visible = True

Open in new window


Any suggestions ?
0
I am getting below error


[INFO] Scanning for projects...
Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.example.howtodoinjava:spring-boot-soap-service:0.0.1-SNAPSHOT: Failure to find org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.M4 in http://111.2.222.111:8081/archiva/repository/internal was cached in the local repository, resolution will not be reattempted until the update interval of archiva has elapsed or updates are forced and 'parent.relativePath' points at no local POM @ line 14, column 10
 @
The build could not read 1 project -> [Help 1]
 
  The project com.example.howtodoinjava:spring-boot-soap-service:0.0.1-SNAPSHOT (C:\Users\gmy\tes\spring boot_webservices_soap_rest\spring-boot-soap-service\pom.xml) has 1 error
    Non-resolvable parent POM for com.example.howtodoinjava:spring-boot-soap-service:0.0.1-SNAPSHOT: Failure to find org.springframework.boot:spring-boot-starter-parent:pom:2.0.0.M4 in http://111.2.222.111:8081/archiva/repository/internal was cached in the local repository, resolution will not be reattempted until the update interval of archiva has elapsed or updates are forced and 'parent.relativePath' points at no local POM @ line 14, column 10 -> [Help 2]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

0
spring boot security

how SimplePasswordValidationCallbackHandler dfferent from other implementatons like
SpringCertificateValidationCallbackHandler

SpringDigestPasswordValidationCallbackHandler


what is meaning of call back handler

Please advise
0
apart from the "Elements" at top like GetCourseDetailsRequest, GetCourseDetailsResponse
 why we have Types at bottom like Status and CourseDetails at the bottom
<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://xyz.com/courses" xmlns:tns="http://xyz.com/courses"
	elementFormDefault="qualified">

	<xs:element name="GetCourseDetailsRequest">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="id" type="xs:int" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>

	<xs:element name="GetCourseDetailsResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="CourseDetails" type="tns:CourseDetails" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>

	<xs:element name="GetAllCourseDetailsRequest">
		<xs:complexType>
		</xs:complexType>
	</xs:element>

	<xs:element name="GetAllCourseDetailsResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="CourseDetails" type="tns:CourseDetails"
					maxOccurs="unbounded" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>

	<xs:element name="DeleteCourseDetailsRequest">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="id" type="xs:int" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>

	<xs:element name="DeleteCourseDetailsResponse">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="status" type="tns:Status" />
			</xs:sequence>
		</xs:complexType>
	</xs:element>

	<xs:simpleType name="Status">
		

Open in new window

0
Get expert help—faster!
LVL 12
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

<wsdl:portType name="CoursePort">...</wsdl:portType>
<wsdl:binding name="CoursePortSoap11" type="tns:CoursePort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="GetAllCourseDetails">


Similar to above SOAP over http


any examples on below

<wsdl:portType name="CoursePort">...</wsdl:portType>
<wsdl:binding name="CoursePortSoap11" type="tns:CoursePort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/mq"/>
<wsdl:operation name="GetAllCourseDetails">


basically i am looking for examples on soap over mq not soap over http
what are advantages, disadvantages, practical uses of SOAP over MQ vs SOAP over http
Please advise
0
hi,
while working with the SOAP web service i gave below as request from wizdler.

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
   
   
    <Body>
        <GetCourseDetailsRequest xmlns="http://xyz.com/courses">
            <id>123</id>
        </GetCourseDetailsRequest>
    </Body>
</Envelope>

i am getting below response when i click go button with POST method selected from drop down

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <faultcode>SOAP-ENV:Client</faultcode>
            <faultstring xml:lang="en">com.sun.xml.wss.XWSSecurityException: Message does not conform to configured policy [ AuthenticationTokenPolicy(S) ]:  No Security Header found; nested exception is com.sun.xml.wss.XWSSecurityException: com.sun.xml.wss.XWSSecurityException: Message does not conform to configured policy [ AuthenticationTokenPolicy(S) ]:  No Security Header found</faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


can you please advise how to resolve this
whizler1.png
0
I followed this video to use ticketing authentication with Qlik Sense using .Net
But received this error message at the end:
Certificate not found! Verify AppPool credentials.

Open in new window


Verified the application server that accessing the Qlik virtual proxy has the certificate (checked in the certificate Personal folder). What could be the issue that the authentication failed?
0
while executing spring boot soap example keep getting error like below

Description:

The Tomcat connector configured to listen on port 8081 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 8081, or configure this application to listen on another port.


I tried 8080 as well in application.properties even that did not work


how to find what ports are free on my windows 10 laptop to use that ?

please advise
0
what are differences between project explorer and package explorer in eclipse.

how to open package explorer by default when opening eclipse

Please advise
0
I'm working on a program to track plants for a nursery and am having an problem structuring the database.  For each plant there can be multiple crops each year. Each crop is divided into different descriptors when its entered in inventory. (graft, size1, size2, etc...) As the plant grows it can be shifted from one descriptor to the next.  
 I need to be able to track by crop number and only use a descriptor once for the plant.  For example: Crop1, Crop2, Crop3...  Descriptor: size1   I need to be able to get a total count from all the plants that have a specific descriptor regardless of what crop its from.  
Right now I have a table for Plants, Crop, Inventory. Each Plant has multiple Crops, each Crop has multiple inventory records.  Portions of the crop may be pre-sold so the same descriptor could be used for two different inventory records with one being marked as pre-sold.
0
Are SOAP web services are state-full

I read REST ones are stateless

https://www.tutorialspoint.com/restful/restful_statelessness.htm

Please advise
0
I followed a tutorial to add multiple app config files, for different environments,  to a console application project.  This is how it is structured in the visual studio (see below at the end)
Basically, idea is to use transformation to replace the values in the config file based on the environment.

one issue, I'm running into is now when I try to remove the UAT and Live config files and try to build the project. it complains those files are missing.
I know these files are not needed to build the solution and I cannot find anywhere where these files are referenced in the project.
why is visual studio complaining about these files missing, when it doesn't need these files in the first place? also i get same error from the command line, when i use msbuild.


App.config
  App.UAT.config
  App.Live.config
0
I'm working with the Duo Auth API and I've run into a minor hitch. When requesting a logo the response is a string which apparently contains the logo as "Content-Type image/png". Specifically, the documentation states
On success, the response body is Content-Type image/png, containing the logo.
(Link here: https://duo.com/docs/authapi#first-steps)
My question is, having successfully retrieved the response, how do I convert the string value into a usable png image?
0
Free Tool: SSL Checker
LVL 12
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

How can I show a custom error page for a security error. For example, if a user enters forbidden text into an input box such as: <script>alert(123)</script>, the user is redirected to errorforbidden.aspx.  I have ValidateRequest="true".

Code is vb.net
0
We are trying to connect to a web service that is using an API Key for access. How can we do that?

In Visual Studio, first we created a service reference in the project using the provided WSDL file.

This is the code that I use now to establish the connection and send the request:

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

        Dim lsRemoteAdress As System.ServiceModel.EndpointAddress
        Dim lsEndPointAdress As String ={remote address}
        lsRemoteAdress = New System.ServiceModel.EndpointAddress(lsEndPointAdress)

        ' Create binding
        Dim lsBinding As New WSHttpBinding   '  System.ServiceModel.BasicHttpBinding()
        With lsBinding
            .Name = "NameBinding"
            .Security.Mode = SecurityMode.Transport
            .Security.Transport.ClientCredentialType = HttpClientCredentialType.None
        End With

        ' Set api_key to endpoint
        Dim lsURI As Uri = New Uri(lsEndPointAdress)
        Dim addressHeader1 As AddressHeader = AddressHeader.CreateAddressHeader("api_key", "api_key", {received api})
        Dim addressHeaders() As AddressHeader = {addressHeader1}
        lsRemoteAdress = New System.ServiceModel.EndpointAddress(lsURI, addressHeaders)
        Dim lsPortalServiceClient As New ServiceReferenceName.ProjectenPortClient(lsBinding, lsRemoteAdress)

        ' Create request
        Dim lsgetProjectenRequest As New …
0
Please give the  general guidelined or best practices to  resize the WPF UI and screen based on the screen resolution
0
I had this question after viewing Export VSD to JPG using C#.

Hi All,

I have to Convert number of Visio files to .Png Files and I Should Apply the settings to PNG File, reducing the size of the file during the time of Conversion as per the attachment.
Could you Please help me anyone how to do this in C#.Net Automatically?
0
Error 193: 0xc1 when starting windows service what is problam i didnot understand
0
hi,

Wonder why screen 2 approach better than screen 1 approach.
Please advise
screen2.png
screen1.png
0

.NET Programming

133K

Solutions

38K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.