C#
C#

help

Root Question Message

Lary
Lary8/11/2022
Fetch api response status code always 200

.then(function (response) {
            if (response.ok) {
                success.innerHTML = "SUCCESS";
                setTimeout(function() {
                    location.reload();
                }, 1000);
            }
            else if(response.status === 404){
                message.innerHTML = "*User not found*";
            }
            else{
                message.innerHTML = "*Server error*";
            }
        })

I am returning things like
return new JsonResult(StatusCode(404));
in the back end and I saw it return this. Like I wanted. But I guess I don't know how to work with this result in the javascript.
Message Not Public

Sign In and Join Server To See

8/11/2022
jcotton42
jcotton428/11/2022
Oh whoops
Message Not Public

Sign In and Join Server To See

8/11/2022
Lary
Lary8/11/2022
My method is
public async Task<JsonResult> UserLogin([FromBody] AccountRead2 account)
Is it correct?
jcotton42
jcotton428/11/2022
Misread 404 as 400
jcotton42
jcotton428/11/2022
Use NotFound yeah
Message Not Public

Sign In and Join Server To See

8/11/2022
Lary
Lary8/11/2022
NotFoundResult cannot be converted into JsonResult it says
Message Not Public

Sign In and Join Server To See

8/11/2022
jcotton42
jcotton428/11/2022
The return type should be ActionResult
Lary
Lary8/11/2022
Let's see. I am running it
Message Not Public

Sign In and Join Server To See

8/11/2022
Lary
Lary8/11/2022
hell yes
Lary
Lary8/11/2022
it worked thanks
Lary
Lary8/11/2022
And statusCode(530) works I guess
Lary
Lary8/11/2022
I added it for some other thing now
jcotton42
jcotton428/11/2022
530?
Lary
Lary8/11/2022
custom, 500+ should be server sided errors right?
jcotton42
jcotton428/11/2022
What are you using 530 to represent?
Lary
Lary8/11/2022
I am creating a jwt for user login. Or there are various places that may be caused by my coding. If this jwt fails, I am sending 530. That's largely to inform me.
Lary
Lary8/11/2022
for development process
Lary
Lary8/11/2022
530 is site is frozen error I guess. But it shouldn't matter
jcotton42
jcotton428/11/2022
If the JWT fails?
Lary
Lary8/11/2022
if creating jwt string method fails
Message Not Public

Sign In and Join Server To See

8/11/2022
Lary
Lary8/11/2022
that's why I said it's not for the user. Who knows which one of my fingers may create a disturbance in that method in the next few months.
Lary
Lary8/11/2022
I am leaving for dinner, don't mind me if I can't answer. THANK YOU once more. I would struggle even now
Message Not Public

Sign In and Join Server To See

8/11/2022
Message Not Public

Sign In and Join Server To See

8/11/2022
Message Not Public

Sign In and Join Server To See

8/11/2022
Message Not Public

Sign In and Join Server To See

8/11/2022
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy