The remote server returned an error: (403) Forbidden

后端 未结 10 1414
半阙折子戏
半阙折子戏 2020-12-15 03:16

I\'ve written an app that has worked fine for months, in the last few days I\'ve been getting the error below on the installed version only.

If I run the source code

10条回答
  •  春和景丽
    2020-12-15 04:13

    Add the following line:

    request.UseDefaultCredentials = true;
    

    This will let the application use the credentials of the logged in user to access the site. If it's returning 403, clearly it's expecting authentication.

    It's also possible that you (now?) have an authenticating proxy in between you and the remote site. In which case, try:

    request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
    

    Hope this helps.

提交回复
热议问题