Http Client Protocol Issues

If you use any of these solutions, Please let me know so I can track if any of this is useful to you! Thanks! This is an area to share observations I have made working with Http Client Protocols and the associated technologies. I currently work for the Microsoft team that supports the WinInet, WinHTTP and System.Net API's and classes associated with these technologies. This is not a replacement for Microsoft Support, but an area to discuss these technologies. These postings are provided "AS IS" with no warranties, and confer no rights. Use of included code samples are subject to the terms specified at Microsoft - Information on Terms of Use

Using .NET HttpWebRequest class with SiteMinder you get a 403 or 401 error

Download Fiddler from http://fiddlertool.com and run this for an Internet Explorer browser session that successfully connects.

 

Then hit the same site with your .NET 2.0 client application and make sure you set the credentials in your code as well: http://msdn.microsoft.com/en-us/library/system.net.networkcredential.aspx  (Note you can set myCreds directly on the Credentials property of the HttpWebRequest object... no need for the Credential Cache object, but it will not hurt anything).

 

Compare the two traces in Fiddler in the Sessions Tab on the right side.  If the credentials are successfully passed you should see the 401 challenge from the site answered with the same Basic Authentication header (a base 64 encoded jumble of characters).  If they are the same then you are passing the credentials correctly so what could be the problem?

 

Using my post on http troubleshooting: http://blogs.msdn.com/jpsanders/archive/2008/06/25/troubleshooting-code-that-uses-the-http-protocol.aspx

 

 

to simplify the issue you will see no Cookies in the failed case.  What is going on?

 

The .NET classes do not implement a cookie container by default and if you wish to use cookies, you need to provide a cookie container.  You may want to make this container global to your app or simply local to the function (this is your design decision).  Here is the documentation:

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.cookiecontainer.aspx

 

Implement the container and use Fiddler once again if it does not work to ensure the successful and failed cases send the exact same data (hint they do not send the same headers and data if this fails still).

 

Published Thursday, December 11, 2008 11:22 AM by jpsanders

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Submit

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker