Hello Tasneem Nomani,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
Problem
I understand that you are having an error: "An error occurred while processing your request" during submission of your asp.net mvc web application hosted as azure app service mostly after a week deployment and error code 4005 Forms authentication failed for the request and reason: "The ticket supplied has expired." was found in the log.
Solution
The error indicates that the authentication ticket (cookie) used for Forms Authentication has expired. This issue can occur if the authentication ticket's expiration is set to a short duration or if there's a mismatch between the ticket's expiration and the application's session timeout.
The followings are possible solution I can think of:
- In the
web.config
file, check thetimeout
attribute in the<forms>
tag under<authentication>
. You might want to increase this value to a more extended period that matches the expected user activity duration this will increase the Timeout Duration:
Here,<authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" /> </authentication>
timeout="2880"
sets the expiration to 2880 minutes (48 hours). - Ensure that the
slidingExpiration
attribute is set totrue
. This will reset the expiration time each time the user makes a request, keeping the user logged in as long as they are active. For example:<authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" slidingExpiration="true" /> </authentication>
- Ensure that the
<machineKey>
element in theweb.config
file is explicitly set, as inconsistent machine keys can lead to issues with authentication cookies. For example:<machineKey validationKey="A_VALIDATION_KEY" decryptionKey="A_DECRYPTION_KEY" validation="SHA1" />
- Look into the scaling settings, app service plan configuration, and any potential memory issues.
Accept Answer
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.
Best Regards,
Sina Salam