Home > Net >  Request the interrupt webApi how to know
Request the interrupt webApi how to know

Time:10-18

Everybody is good, I want to know about the, the.net webapi project, if the client request, the controller receives the request and then began to perform a series of processing operations. But there will be requests interruption. So I want to return to process the results, assess the current state of the request, if the interrupt, I'd like to proceed to rollback operation. What do you have experience to share. Thank you

CodePudding user response:

HTTP is stateless,
No requests interruption,
Rolled back, and you should be in view of the current logic is unusual, in operation,
So no matter how,
You will return a result to the other party, unless the other broken network, then the local tip timeout,
Otherwise, abnormal or not, as a result, there will be a wrapper class to feedback you rollback of the rollback, normal data is returned to normal,

CodePudding user response:

reference
but there will be a request interrupt may


This may, how do you prove?

At the very least, you should have evidence to prove that the "interruptions" exists.

In said, if you said that the establishment of the interrupted you also can return? It also called "interrupt"...

To prove the existence of the first. Talking about the next step.

CodePudding user response:

Or you just launched two requests, you don't want to rollback is revoked before data manipulation,,

CodePudding user response:

This don't see him online or not online, HTTP didn't ability to know, this is said I need customer to confirm whether the business

12306, for example, jingdong, for example, in the case of payment stage, pay no success, success at net silver to confirm, not confirm all stay in the payment list, this list lasts for 20 minutes (usually) -- -- -- -- -- -- -- the day before yesterday I book train tickets, for example, just at the subway exit, just phone signal is bad, just stuck in the paypal payment link, then 12306 told you, I want to retreat? No retreat, 12306 back to wait for payment confirmation (this is the business logic, not disconnect constantly open) 20 minutes until timeout haven't handle

So do not request "broken" is not "broken", but the business logic validation,

CodePudding user response:

Through HttpContex RequestAborted can realize
Asp. Net core development team has been considering this kind of situation

CodePudding user response:

reference DF 5 floor - SKy reply:
by HttpContex RequestAborted can
Asp. Net core development team has considered the situation the


Ok, I try, because Java is a mechanism to capture the interruption of abnormal, I think. Net should also have.

thank you

CodePudding user response:

reference DF 5 floor - SKy reply:
by HttpContex RequestAborted can
Asp. Net core development team has considered the situation the




HttpContext. RequestAborted. IsCancellationRequested

This can really know if interrupt request, but the HttpContext object, in the project of webapi is unable to get to.

Although they are in the System. Two classes under the Web namespace

But in the properties of the HttpContext Controller is a HttpContextBase type (real HttpContextWrapper type, is to the System. Web. The HttpContext a wrapper), System. Web. HttpContext is a type, there is no inheritance relationships between these two classes.

So to get the HttpContext object in the controller, seems to be no way. Don't know if you know more ways.

thank you

CodePudding user response:

Do not spray,
Before I make a similar
Finally realize the
Add a label field, and in the cache before polling, and if you have any cancel operation in time the user is not put in storage or execute the batch update

CodePudding user response:

refer to the eighth floor Liu Cai ghost reply:
not spray,
Before I make a similar
Finally realize the
Add a label field, and in the cache before polling, and if you have any cancel operation in time the user is not put in storage or execute the batch update


How do you know the user closes the browser?

CodePudding user response:

references 9 f java__net response:
how do you know the user closes the browser?


Because the data in the cache is immediately shut down the browser does not have an impact on libraries
  • Related