Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
840 views
in Technique[技术] by (71.8m points)

c# - How can I prevent random 403 Forbidden Errors using Unity WebRequest?

I am trying to access my PHP files on my cpanel from my C# code in my Unity Project. Most of the time, the webrequests work completely fine and can access the PHP files. However, if I click around a few times (amount of clicks and speed of clicks differ every time), Unity throws a 403 Forbidden error at me and I can no longer access my PHP files for anything.

Is there anything I can do to prevent this from happening? Is it a Unity thing? I am new to PHP, and this is my first major project in Unity.

This is the error I get:

HTTP/1.1 403 Forbidden
UnityEngine.Debug:Log(Object)
<GetContent>d__7:MoveNext() (at Assets/Scripts/WebBehaviour.cs:364)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

This is the line of code (364) but it is just debug code to print out the webrequest error:

UnityEngine.Debug.Log(webRequest.error);

My functions work completely fine most of the time.

Thank you!

question from:https://stackoverflow.com/questions/65881737/how-can-i-prevent-random-403-forbidden-errors-using-unity-webrequest

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...