locked
Redirect to login page, some times when i click on page(s)! RRS feed

  • Question

  • User-79977429 posted

    Hi

    i'm facing some problems!

    1. Facing the Validation of viewstate MAC failed problem.
    2. After that, some times when i click on some pages, redirect to login page, I think the session is expired soon!

    Where is the problem and how to solve it ?

    Updated : I've used shared hosting & i think this caused the problem. after some search, i've add sessionSate tag in web.config as follow :

    <sessionState mode="InProc" timeout="20" ></sessionState>

    but my problem was not solved. Also after contacting with my hosting provider, they could not make changes to my appPool.

    Can anybody help me how to work around this problem ?

    thanks in advance

    Saturday, May 25, 2019 6:20 PM

All replies

  • User-2054057000 posted

    Add:

    <sessionState mode="InProc" timeout="20" cookieless="true"></sessionState>

    Sunday, May 26, 2019 12:51 PM
  • User-79977429 posted

    Thanks for reply

    I've add your advise without cookieless attribute, now add this attribute and test again and not working!

    Also, after adding cookieless attribute, i'm facing some errors such as "Authentication Faield : invalid operation exception!"

    Sunday, May 26, 2019 4:21 PM
  • User-893317190 posted

    Hi hamed_1983,

    If you are using web farm, session state in proc will not work, because your session data will stored separately in   all your servers.

    If you store session in one server and then the user visits another server , the server will not have the session data.

    So you should use session in state server or sql server.

    To learn how to configure session state , you could refer to

    https://www.sitepoint.com/premium/books/the-asp-net-2-0-anthology-101-essential-tips-tricks-hacks/preview/how-can-i-maintain-session-state-in-a-web-farm-using-a-state-server-81c187c

    https://www.c-sharpcorner.com/UploadFile/25c78a/load-balancing-session-state-configuration/

    Best regards,

    Ackerly Xu

    Monday, May 27, 2019 3:20 AM
  • User-79977429 posted

    Thanks for reply

    Your advise was very well to me, I found out to solve my problem, should using either 'StateServer' or 'SqlServer'. (i've focus on SqlServer mode and have found this useful link), but because my site hosted on shared hosting provider, i could not access some server features, like jobs, or services. Also, i want to use the same database which i used in my site, instead of create a custom database for storing session data. So :

    1. How can i configure my site database to store session data ?
    2. Can i configure above item or my Hosting provider ?

    Thanks in advance

    Monday, May 27, 2019 10:44 AM
  • User-893317190 posted

    Hi hamed_1983,

    You should use aspnet_regsql.exe  to help create session state tables in your database.

    Usually it is in C:\Windows\Microsoft.NET\Framework64\your framework version> or C:\Windows\Microsoft.NET\Framework\your framework version>.

    Then use cmd to enter this folder and input command

    aspnet_regsql.exe -S  [your server ip] -U [username] -P [password]  -ssadd -sstype c -d [databasename]

    then you database should have two extra tables ASPStateTempApplications and ASPStateTempSessions, you could set -d parameter to your website's database and you don't need to create a new database.

    Then you could  configure sessionstate in your web.config.

       <sessionState mode="SQLServer" sqlConnectionString="server=[your server];database=[database name];uid=[username];pwd=[password]" allowCustomSqlDatabase="true"  cookieless="false"  timeout="20" />
      </system.web>

    You had better use username + password instead of  windows authentication, because you have  several servers.

    If you don't have a user in your database, please refer to https://www.guru99.com/sql-server-create-user.html

    Also refer to https://blogs.msdn.microsoft.com/akshayns/2008/10/04/how-to-configure-sql-server-to-store-session-state/

    Best regards,

    Ackerly Xu

    Tuesday, May 28, 2019 2:15 AM