WebAPI POST value always null?

Do you have value always null for POST in WebAPI?

public string Post([FromBody]string value){}?

Fix:

It is a known WebAPI issue. Use the jQuery POST function like this:

$.post(“Data”,{”:’test’}

OR

$.post(“Data”,’=’+’test’

 

Force download a file/string/content from WCF service to browser

This post is about pushing return value of WCF method calls directly to browser.

Below are the additional configurations required:

<services>
      <service name=”WcfService1.Service1″>
        <endpoint behaviorConfiguration=”webBehavior” binding=”webHttpBinding” contract=”WcfService1.IService1″ />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
          <behavior name=”webBehavior”>
            <webHttp />
          </behavior>
      </endpointBehaviors>

</behaviors>

 

In the code, you will have to use [WebGet] like:

[WebGet]
[OperationContract]
string GetData(int value);
[WebGet]
[OperationContract]
string GetString();

[WebGet]
[OperationContract]
Stream GetFile(string barcode, string timestamp);

 

Methods will look like:

public string GetData(int value)
        {
            return string.Format(“You entered: {0}”, value);
        }
        public string GetString()
        {
            return “Hello World”;
        }

        public Stream GetFile(string barcode, string timestamp)
        {
            WebOperationContext.Current.OutgoingResponse.ContentType = “text/plain”;
            WebOperationContext.Current.OutgoingResponse.Headers[“Content-Disposition”] = “attachment; filename=”file1.prn””;

            MemoryStream stream = new MemoryStream();
            StreamWriter writer = new StreamWriter(stream);
            writer.Write(“Hello World”);
            writer.Flush();
            stream.Position = 0;
            return stream;
        }

 

 

Now you can invoke the method from browser using:

 

Sorry for this non-user friendly post.

 

eBook – Data Access for Highly-Scalable Solutions: Using SQL, NoSQL, and Polyglot Persistence

This guide describes how to design and build applications and services that can take best advantage of SQL and NoSQL databases by combining them into a polyglot solution. It provides an end to end walkthrough of a business application that uses SQL Server in conjunction with a variety of NoSQL databases, showing how the designers selected the databases to closely match the business requirements.

URL here.

 

Drawing using Spatial Data (Geometry) in T-SQL

Try executing this in SSMS.

You should be able to see an ‘H’ in ‘Spatial results tab’

image

You can find the reference reading here – http://technet.microsoft.com/en-us/library/bb933790.aspx

 

Polygon drawing tool in C#

image

You just have to input the graph points x1 y1, x2 y2, x3 y3 etc. It will draw filled polygon in the diagram.

Here is the source code:

Note that I have used a timer with 500 milliseconds for auto update. I can share the solution zip with you if the request is within two weeks. I usually dump my experiment projects.