Hello,
I have a windows hosting plan on a server in the US. In there I have 2 virtual directories. One contains a webservice (asmx file) and the other an aspx page.
I also have a windows mobile app which needs to invoke a method of the webservice. This works great! No problems at all..
However, when I use
the exact same code for the credentials in the aspx page which calls the asmx web service, it returns The request failed with HTTP status 401: Unauthorized. It doesn't give any other value ie 401.1, 401.2 etc..
If I try to access the web service manually or through VS2008 it works great as well! The problem occurs only when I use an aspx page which invokes the asmx web service.
The code I use is in VB.net and is the following:
Public serviceA As New webreferenceservice.ServiceB
Dim mycreds As New System.Net.CredentialCache()
Dim creds As New System.Net.NetworkCredential("username", "pass")
mycreds.Add(New Uri("http://site.com/virtualdir/webservice.asmx"), "Negotiate", creds)
ServiceA.Credentials = mycreds
It works great on the mobile and I copied-pasted it into the aspx.vb file.
Things I have tried:
1. Added <identity impersonate="true" />
2. Tried ServiceA.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials and ServiceA.Credentials = System.Net.CredentialCache.DefaultCredentials
I have read some things in the forums regarding the sharing options etc but the account I use is the only one my hosting provider allows and it is the one for remote management of the website through IIS. However IIS does not have any options regarding folder properties when I right click on the virtual folder, probably due to restrictions.
Could you please help me find a solution?