Undefined object reference for an object instance.?

Asked

Viewed 873 times

1

Can anyone help me with the error below? I implemented based on this link Permissioncookie

inserir a descrição da imagem aqui

  • 1

    Your Session[".PermissionCookie"] has null value.

1 answer

0


This error happens for a very simple reason: after a certain time, preset in your web.config, the cookie is deleted from browser.

This is a certain precaution for your application.

But to circumvent this error is simple:

Go on your web.config in your project just add to tag <autentication>, as follows below.

<system.web>
<authentication mode="Forms">
<forms timeout="28" loginUrl="/Autenticacao/Index"></forms>
</authentication>   
</system.web>

Explaining: THE timeout is the time that the cookie will stay active in the browser and after time expires redirects to the login page.

As you used my question as a basis, I did not do any treatment to show any message to the user, but if you want to implement this idea, it would be nice. It’s an alternative not to show this IIS screen.

EDIT

This error also occurs because necessarily some user needs to be logged in to the page where the .Permisioncookie is used.

This happens because user information is verified in this cookie which is created as soon as the Session goes up in the system, that is, as soon as the user actually logs in to the system. If there is no logged in user, the Session is not created and consequently neither cookie and so this mistake appears, not knowing that cookie is the one the page requires, and arrow the value of the cookie as null.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.