Archive for category Web Services
IIS 7.x and HttpResponse.Headers
Posted by suddenelfilio in .net, Asp.net, Programming, Web Services on 15/07/2011
Today I was debugging some application I wrote that was written with an application pool’s mode set to Integrated mode in mind. One of my colleagues told me I needed to test it running in an application pool with its mode set to Classic.
And guess what? Boom… it blew up in my face! After cursing around a bit I discovered in my log files the following message:
ERROR An Exception was thrown:System.PlatformNotSupportedException: This operation requires IIS integrated pipeline mode.
at System.Web.HttpResponse.get_Headers()
The defect piece of code was this:
HttpContext.Current.Response.Headers.Add("Some-Header","Some-Value");
Apparently to do that you need the IIS integrated pipeline mode. Well if you really need to run your app pool in Classic mode just replace your code with the following and all is well:
HttpContext.Current.Response.AppendHeader("Some-Header","Some-Value");
I know it’s kind of silly from Microsoft to not make this both ways compatible.
Some Suddenelfilio.net changes.
Posted by suddenelfilio in Blog, General, Hosting, Web & Design, Web Services, wordpress on 11/09/2010
As I mentioned earlier on this blog suddenelfilio.net now uses the Disqus Commenting & Discussion system to handle comments on blogs. It is a really nice systems that integrates perfectly with WordPress on which this blog is running.
LinkedIn OAuth using Hammock in C# & ASP.NET
Posted by suddenelfilio in .net, Web & Design, Web Services on 24/08/2010
UPDATE: Hammock moved to github https://github.com/danielcrenna/hammock
Codeplex.com description of Hammock:
Hammock is a REST library for .NET that greatly simplifies consuming and wrapping RESTful services.

I’m currently working on a little web project that needed integration with LinkedIn.com. The LinkedIn API allows for OAuth authorization and authentication. They describe the process of getting a request token, authorizing it by the user and then getting an access token. Standard OAuth you might say. So I needed a way to do this in C# and found the Hammock library. Although Hammock does not only do OAuth I used it for that purpose only at the moment.
Below is the code I wrote to get a request token and send the user to the authorization page at Linkedin:
public void RequestAndAuthorize()
{
var credentials = new OAuthCredentials
{
CallbackUrl = "http://127.0.0.1/oauth/callback/",
ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"],
Verifier = "123456",
Type = OAuthType.RequestToken
};
var client = new RestClient { Authority = "https://api.linkedin.com/uas/oauth", Credentials = credentials };
var request = new RestRequest { Path = "requestToken" };
RestResponse response = client.Request(request);
string token = response.Content.Split('&').Where(s => s.StartsWith("oauth_token=")).Single().Split('=')[1];
string token_secret = response.Content.Split('&').Where(s => s.StartsWith("oauth_token_secret=")).Single().Split('=')[1];
Response.Redirect("https://api.linkedin.com/uas/oauth?oauth_token=" + token);
}
Once the user has authorized your request token the LinkedIn server will redirect the user back to the callback url in this case this is http://127.0.0.1/oauth/callback. Using the returned oauth_token and oauth_token_secret (you got this one while requesting a request token) you can now get an access token so you can start making authenticated API calls from you application on behalf of the user.
This is the code that is used when the callback url is called:
public void Callback()
{
var credentials = new OAuthCredentials
{
ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"],
ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"],
Token = token,
TokenSecret = token_secret,
Verifier = verifier,
Type = OAuthType.AccessToken,
ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
SignatureMethod = OAuthSignatureMethod.HmacSha1,
Version = "1.0"
};
var client = new RestClient { Authority = "https://api.linkedin.com/uas/oauth", Credentials = credentials, Method = WebMethod.Post };
var request = new RestRequest { Path = "accessToken" };
RestResponse response = client.Request(request);
string content = response.Content;
}
As you can see Hammock is really nice and allows for easy OAuth authentication/authorization to be used.
UPDATE: MS Tag REST service issues
Posted by suddenelfilio in .net, MSTagLib, Web Services on 03/08/2010
During the last 24 hours the service has been experiencing some issues when called. This has currently been resolved. If you’ve received an http 500 error code when calling the service please try again. The issue was introduced when I extended the service to record certain metrics. These metrics or stats can be seen on http://tag.ws.suddenelfilio.net/ at the end of the page.
If you experience any other problems please contact me at: mstaglib@suddenelfilio.net
MS Tag REST interface updated
Posted by suddenelfilio in MSTagLib, Web Services on 30/07/2010
Today I’ve updated the Microsoft Tag REST interface over at http://tag.ws.suddenelfilio.net/.
Since Microsoft released Tag I was a bit behind to update the interface to include the GetTagID functionality. This is now made up for and the service available for all to enjoy.
I also updated the documentation on how to use the REST interface to get a Tag’s id.
If you experience any problems please let me know using the address that you can find over at http://tag.ws.suddenelfilio.net/ or leave a comment on this page!
Suddenelfilio Products & Services
Posted by suddenelfilio in .net, Blog, General, Hosting, MSTagLib, Web & Design, Web Services, wordpress on 21/06/2010
As of now Suddenelfilio.net is offering various products and services for those interested. Currently we offer 2 technology offers:
1. Microsoft Tag: suddenelfilio.net can help you with your Microsoft Tag needs.
2. WordPress Services: for a simple blog or wordpress as cms we can help you!
Have a look at the Products & Services page for more information.
Release of Ril#
Posted by suddenelfilio in .net, Web & Design, Web Services on 12/05/2010
Today I released the website for my latest personal project, a .net library for the Read It Later Service API. Through their api you can create your own client application. Using Ril# this is now easy to do in .net.
Have a look at http://rilsharp.suddenelfilio.net
MS Tag REST Certificate Issues
Posted by suddenelfilio in .net, MSTagLib, Web & Design, Web Services on 28/04/2010
This week I received an email telling me that they got an error while using the MS Tag REST service:
System.ServiceModel.Security.SecurityNegotiationException: Could not establish trust relationship for the SSL/TLS secure channel with authority ‘ws.tag.microsoft.com‘.
As you can see the authority is complaining about the Microsoft domain. The issue was the certificate used by Microsoft’s Tag API was outdated and thus the error was thrown when the REST service communicated with the Microsoft service.
Since the certificate has been renewed and is now valid till somewhere early 2011 this problem should be resolved.
I Like (to) Read It Later
Posted by suddenelfilio in General, Web & Design, Web Services on 01/04/2010
Today I discovered Readitlaterlist.com. This is an online service that allows you to mark pages for reading later on.If you are like me always seeing things you would really like to read but just don’t have the time at the moment you see them and then when you get round to reading them can’t remember what they were? Well this is the ideal solution. You should really have a look at all the applications it integrates with.
The way it works is really simple. First go to the website to create an account then you install a plugin for you browser/mobile phone and you’re set!
When browsing a website and you see something that you like to read later on just click the readitlater icon in the adress bar and it will be stored so you can easily find it back later on. Nice about this is that the list of things you want to read later on is available on every pc/mac/mobile that has the til plugin installed. All popular browser and mobile platforms are supported.
Another very nice feature is the ability to download the resource you would like to read later on so you can read it when you are offline. Like when you put various stuff in your list while working and then on the way home in the train you would like to read them. Because they were downloaded you can even if you 3G reception is bad or even worse not available.
A problem when you want to read a website on a mobile device might be the extensive use of images and all sorts of markup. Ril allows you to convert the resource to be stored as text so it strips out unnecessary markup and presents it in a clean format. This is very handy when catching up on your list from a mobile device.
On top of that they have a very nice application called Digest. What Digest does is it sorts your resources into topics and presents it to you like you are reading blog or newspaper. Consider it like your own Magazine software that updates its content to the stuff you really like to read.On top of that Digest also allows you to share your content with others and access to Digest is possible from all Read It Later apps.
Currently you can get an early beta access to Digest for only $5.
Since I’m a developer myself I also would like to make you aware of the RIL API. So if you are feeling creative give it try and build an amazing mashup or app to integrate with ReadItLater.
I can only say that I really like it a lot! It helps me remember all the fun stuff out there in the digital world I would like to discover.
Microsoft Tag gets an update to their API?
Posted by suddenelfilio in .net, MSTagLib, Visual Studio .Net, Web Services on 12/03/2010
I’ve been reading through the MS Tag support forums over at getsatisfaction.com and noticed that it seems they’ve picked up on adding new features that have been asked as business cases as well as a possible update the TAG API to be released. Note that I have not got any comfimation on all of this but it does make me hopeful!

