Solved

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

Posted on 2012-03-10
3
1,630 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

914 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now