Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

770 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