Solved

jquery ajax problem (un autherized) in asp.net web page

Posted on 2012-03-10
3
1,702 Views
Last Modified: 2012-04-10
hi,

I have ajax method using jquery and it works so fine, but after some time of keeping the page opened, if I click the button (to request web method from server) I got this error message in firebug:

JSON:
Message
      "Authentication failed."
      
StackTrace
      null
      
ExceptionType
      "System.InvalidOperationException"

Response:
{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}


so how can I fix this problem?
0
Comment
Question by:njgroup
  • 2
3 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 37706363
what is the statusCode returned? is it 401?
if u refresh the page are you able to make it run?
0
 

Author Comment

by:njgroup
ID: 37706658
yes, if I refresh the page, its gonna run fine
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 37706668
this is due to session timeout in ajax calls.
you can either customize your ajax response instead of throwing 401 exception:
http://stackoverflow.com/questions/5238854/handling-session-timeout-in-ajax-calls

or, redirect to the login page or to increase expiration session timeout in your web.config or preventing session timeout altogether:
http://xpapad.wordpress.com/2010/06/19/preventing-session-expiration-with-ajax/

for each one of the solution proposed you need to understand the implications first,

cheers
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question