I am new to ASP.Net coding and have written a simple website.
The client sends a POST to my website. The post data is used to perform an update to my database, and save an image on the website. The Response to the client is very simple and could be sent before the database is updated or the image is saved.
My website is currently set up using the Page_Load method
protected void Page_Load(object sender, EventArgs e)
{
UploadData uploadData = new UploadData(Request);
if (uploadData.isValid)
{
UploadDataToDB(uploadData);
SaveImage();
}
}
How can I go about sending the Response to the client immediately, and updating the database and saving the image after I have sent the response?
Use ajax to start async saving using page method which calls a web service or other backend logic. do the db update and image save in backend. if it fails with ajax you have the onError method to notify the user on UI but UI will never be blocked with this approach.