SharePoint Service Getting Intermittent 401 Unauthorized Error

Today I ran into an issue at my client that I thought was worth writing about.

I have created a separte web application for collaboration sites (i.e http://collaboration). The client wanted to have a security trimmed list (Links) of all the collaboration sites that the user was able to access. I did some research and determined an approach using the serach.asmx webservice. I created a new data service referencing
http://collaboration/_vti_bin/search.asmx and configured my search query for the “queryex” method.  I found a good example of what I wanted to do on a blog called  Mikes Notebook (thanks Mike). Here is a reference  http://mikesnotebook.wordpress.com/2012/01/16/global-site-directory-for-sharepoint-2010/.

I am using a data view web part to display the data from the datasource.  The query in the datasource  uses a specific search scope to return all the sites that the logged in user has access to under the specific site collection. It returns the Title, Description of the site and the url.  Here is an example of what it looks like

Collaboration Links Web Part

This code worked in my single server dev envrionment with no issues. In the production environment is was only working randomly.  It was  intermittently failing  with an error.  I could hit F5 to refresh the page and then it would work.   After digging into the uls logs I saw that it was getting a Unauthroized 401 error.

Both of the web front ends have been configured to disable the loopback check. What was happening to the best of my knowledge was probably a double hop type issue, and we are using ntlm.

The request would come in under the load balanced ip address of say 175.xxx.xx.xxx and then it would be on one of the web front ends say 10.xxx.xx.150 and then it would try to call out to the webservice i.e http://collaboration.somesite.com/_vti_bin/search.asmx this call was failing since it would resolve back out to the 175.xxx.xx.xxx ip address.

I ended up putting a host entry in both web front end servers to route collaboration.somesite.com to the local virtualized ip address of the individual web front end.

I hope this may save someone in the future from dealing with a similiar issue. I could envision this happening in other areas as well.

Posted in SharePoint 2010 | Leave a comment

Coca-Cola Freestyle Beverage Machine

Today I had lunch at a local sandwhich shop near my house and I was suprised to see they had a Coca-Cola Freestyle. I saw a tv program on CNBC about Coke probably over a year or so ago where they mentioned this machine. Read about CNBC Coke story…

The machine is an interesting concept. My understanding is that it uses micro dispensing technology from the drug industry. Coke says it uses their proprietary PurePour Technology™. The machine can send data back to Coca-Cola on what drinks are being served up, and with over 100 flavors hopefully you can find something you will like. Most of the beverages allow for you to add a flavored version so you could have Orange Coke, Rasberry Coke, Lime Coke, Cherry Coke, and Vanilla Coke. I tried a Cherry Vanilla Coke.

I drink a lot of Diet Coke and Coke Zero being a programmer and living on caffiene, I have to say my Coke Zero didn’t taste the same. My girlfriend ordered a Dr Pepper and she complained that the taste was different as well. I am curious to what others have to say about their experiences.

I think a few of the downsides are :

  • Lines can form because people are deciding on what new flavors to try
  • You have to touch a screen that hundreds of others are touching and can be dirty.
  • If you want just to get ice for your ice tea you have to wait in line because this machine is also the ice dispenser
  • Normal Coke Zero and Dr. Pepper flavors didn’t taste as good as the old fountain dispenser.

On the positive side:

  • Lot’s of options to make your own favorite drink
  • I can see the machine being a draw in places where there are a lot of kids
  • Help influence the next generation of drinks that Coca-Cola makes.
Posted in Uncategorized | Leave a comment

Best Black Friday Purchases

What was your best black Friday purchase? I finally broke down and purchased an iPad. Looks like there were some deals as low as $399 from non authorized dealers like TJ Maxx and Mervyns. I couldn’t find an official ad but printed out pictures of receipts showing that people bought it for $399 and pictures of a sign in the store with the advertised price and headed down to Walmart to try out their so called “Black Friday Price Matching”. I was unsuccessful in negotiating a price match of $399 on the last remaining 16gb ipad wifi model which had already been opened. I figured maybe they would do it since it had been opened. Note to Walmart, people who generally buy apple products won’t pay full price for something that has been opened and may not even buy it to begin with.

I left Walmart and headed to my local Apple store and picked it up for $458 with another $5 off of there iPad case. I was happy that Apple discounted it some, that’s the least they can do because I am sure the new one will be announced in January. I was trying to wait but damn TiVo with their new iPad app for the TiVo hd premiere and xl. Thats another blog post coming soon.

Posted in Uncategorized | Tagged , , , | Leave a comment

Windows Phone 7 Code Camp project files

Thanks to everyone who attended the code camp class today on Windows Phone 7 development we had a great turnout.  I hope you were able to pick up some tips or get an better understanding of what it takes to develop applications for the phone.   I know we went very quick, and I kind of assumed you had a little knowledge of xaml and silverlight, but I wanted to attempt to present something better than a hello world application for you.   We walked through some of the key items to get started in my opinion.   Here is the code, let me know if you have any questions.  

CodeCamp_ToryDouglas_WP7

Posted in Desert Code Camp, Windows Phone 7 | Tagged | Leave a comment

Handling deserialization errors with Json.net framework on Windows Phone 7

Today I was working on some new functionality for a client’s windows phone 7 application.   We are using json.net framework for handling the json responses from the web service.  I used this framework on  a previous windows phone 7 application with good success.   I am new to the framework so still learning things as the come up.  

I was struggling with deserialization issues where the service is returning null values and my .net objects may have some type that doesn’t support null like say int32.   The framework would throw an expcetion trying to convert a null value to an int, when calling Json.Convert.DeserializeObject(jsonStr, typeOf(mytype)). I don’t control the web service code so i wouldn’t be able to make any changes there.   I decided dig in a look for the help documentation on the newtonsoft json framework(json.net) .

Turns out this method has another overload that can take a JsonSerializerSettings object.   This object will allow us to handling errors that are encountered during deserialization so that it will deserialize the items that it can, if an error happens we can mark it as handled, and it will conttinue.  In my case this is what i needed, it will prevent the method from erroring on me.  Here is a snippet of using that method.

SavedSearchData data = null;
try
{
if (!string.IsNullOrEmpty(jsonStr))
{
data = (SavedSearchData)JsonConvert.DeserializeObject(jsonStr, typeof(SavedSearchData),
new JsonSerializerSettings
{
Error = delegate(object sender, ErrorEventArgs args)
{
Debug.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}
});
data.SavedSearchId = int.Parse(savedSearchId);
}
}
catch (Exception ex)
{
Logger.LogError(ex);
}

You could add the errors to a collection for review later if needed.   I hope you find this post useful when you get hit with this issue.

Posted in What I learned today | Tagged , , | Leave a comment

My first two applications in the Windows MarketPlace for Windows Phone 7

I currently have developed two premiere applications for the Microsoft launch of Windows Phone 7.  You can check them out in the Windows Marketplace.

One was for Kbb.com and the other for Realtor.com Check them out if you have a phone.  I really enjoyed working on both projects.

Posted in Microsoft.Net, Silverlight, Windows Phone 7 | Leave a comment

Desert Code Camp – Nov 13

I will be teaching a class with my colleague Mark Tucker from Neudesic on creating silverlight  applications for Microsoft’s new Windows Phone 7 aka  WP7 at the Desert Code Camp.

Event Location
Chandler – Gilbert Community College Pecos Campus
2626 E Pecos Road
Chandler, AZ 85225

Dates
Starts:
11/13/2010 8:00:00 AM
Ends:
11/13/2010 5:00:00 PM

Posted in Desert Code Camp, Microsoft.Net, Silverlight, Windows Phone 7 | Leave a comment