Windows 8 Pro Tip: HttpClient Exception and Package Capabilities

21 June 2012

Just having a bit of a play around with Windows 8 dev recently in the Release Preview (it's been a big week for MS for sure, with the Surface and Windows Phone 8 announcements) and just came across this little gotcha...

If you create a new project and create a HttpClient object and just want to call a web service, or a page, you may encounter a HttpRequestException (an error occured while sending the request) and then an InnerException:

"An attempt was made to access a socket in a way forbidden by its access permissions"

The first thing you should check is the capabilities you've declared in the Package.appxmanifest; I don't know the exact capability that fixed my issue, but I originally only had Internet (Client) enabled, but when I added Home or Work Networking and Internet (Client & Server) , I stopped getting the error.

Easy fix!

Tags: permissions, capabilities, sockets, Windows 8

Add a Comment

No Comments