AJAX :: Throw Exception Message "Authentication Failed" When Call Webservice Form Javascript

Aug 16, 2010

I was created webservice which has a Method:

[Code]....

Then, in my aspx page, i call that method in javascript, but i get a Exception message is "Authentication Failed", code below:

[Code]....

How to resolve this problem?

View 3 Replies


Similar Messages:

Ajax - Call An ASMX Webservice In Javascript Without Resetting Authentication Timers

Nov 23, 2010

Pinging back to a webservice in ajax from the client keeps the user's session alive, I don't want this to happen. More extensive summary For a website we're developing, we need the client to ping back (in js) to a webservice (ASMX) on the server (IIS7.5). This happens to let the server know that the user is still on the site, and hasn't browsed away to another site. This is as our customer wants to let users lock records, but if they browse away to other sites, then let other people take over those locked records. Perhaps the distinction between the client being on the site but inactive and on another site seems unimportant, but that's kinda irrelevant, I don't get to write the UI spec, I just have to make it work.

My problem is this, the ping stops the user from being timed out on the server through the standard forms authentication timeout mechanism. Not surprising as there is that 30 second ping in the background keeping the session alive. Even though we want to know if the user is still on the site, we want the normal forms authentication timeout mechanism to be honoured. I thought I might be able to fix this by removing the ASP.NET_SessionId and .ASPXAUTH cookies in the XMLHttpRequest that is the server ping, but I can't figure out how to do this. This is how my web service & method are defined:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class PingWS : WebService
{
[WebMethod]
public void SessionActive(string sessionID)
{
// does stuff here
}
This is how I'm calling it in js (request is over HTTPS, :
$.ajax({
type: "POST",
url: "PingWS.asmx/SessionActive",
data: 'sessionID=' + aspSessionID + '}',
beforeSend: function (xhr) {
xhr.setRequestHeader('Cookie', '');
xhr.setRequestHeader('Cookie', 'ASP.NET_SessionId=aaa; .ASPXAUTH=bbb;');
},
dataType: "json"
});

I was trying with the setRequestHeader, but that just appends to the header rather than overwrites the header, and IIS is happy to ignore that junk I added. I'm thinking maybe I should be trying to do this at the server end, someone take PingWS.asmx out of the loop so that it doesn't keep the session active, but I'm not sure how to do this. Although the title of the question is focused on clearing the cookie in the header, I'd be super happy if anyone points out that I'm being really stupid and there is actually a much better way of trying to do what I'm doing.

I'm thinking at this stage maybe I need to add something to the webmethod that says how long this particular page has been inactive, and use that knowledge to timeout manually. That actually sounds pretty easy, so I think I'll do that for now. I'm still convinced that there must be an easy way to do what I originally wanted to do though. Update I'm thinking I'm pretty screwed in terms of cookie manipulation here as both the .ASPXAUTH and ASP.NETSessionId cookie are HttpOnly, which means the browser takes them out of your hands, you can't access them via the document.cookies object. So I would say that leaves me with:

Updating my SessionAlive webmethod to track each request so I can tell how long the user has been sitting idle on a page and timeout if needs be Marking the .asmx page somehow on the server end so that it's taken out of the normal authentication/session tracking flow I know how to do 1. so I'll start there but 2. seems much cleaner to me.

View 3 Replies

Javascript - Apostrophe In Ajax Webservice Call?

Jan 28, 2011

I'm calling a webservice using jQuery with .ajaxHere are the data parameters for the call:

var parameters = "{'Titre':'" + Titre + "','Description':'" + Description + "','Contact':'" + Contact + "','VilleId':'" + VilleId + "','QuartierId':'" + QuartierId + "','UserId':'" + UserId + "'}";
It works fine. But when parameters Description or Titre contain the ' character , no call!!!

Does anyone have an idea how can i make it work even with apostrophe character in Titre and/or Description?

View 4 Replies

AJAX :: Call A Webservice Method Fom Javascript?

Mar 10, 2010

I am trying to call a webservice method fom javascript.Every thing goes fine. But,problem is that, I can't return any value from the function.

View 3 Replies

AJAX :: Call Webservice Using Javascript And Scriptmanager Not Working

May 13, 2010

Configuration : Windows Vista,VS 2005,Ajax v1.0.61025 My Html Page

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function fnCall()
{
try
{
var ans= Sim.Service.HelloWorld(OnMethodSucceeded, OnMethodFailed);
}
catch(e)
{
alert(e.message);
}
}
function OnMethodSucceeded(result)
{
alert('a');
}
function OnMethodFailed(result)
{
alert('b');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" ><Services>
<asp:ServiceReference Path="http://localhost/ajaxtest/service.asmx" /></Services>
</asp:ScriptManager>
<div><input id="Button1" type="button" value="button" onclick="fnCall();" /></div>
</form>
</body>
</html>
Web Service CS.
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
namespace Sim
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
public Service()
{
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod,ScriptMethod(UseHttpGet=true)]
public string HelloWorld()
{
return "Hello World";
}
}
}

But i am getting Sim is not defined. Error. post ur comments. I have reviewed most of the forums. I am not able to clear

View 13 Replies

AJAX :: Webservice Call From Javascript Fails If Masterpage In Force?

Mar 2, 2010

I am calling a web service via Javascript. I tried it first in a web page that does not have a Masterpage and it worked perfectly. Then I moved everything over to a web page that does use a Masterpage, and I get a "Microsoft JScript runtime error: Object required" on the javascript statement that calls the web service. My javascript statements look like so:

[Code]....

The web service looks like:

[Code]....

The page source is:

[Code]....

View 5 Replies

AJAX :: Call Webservice Method From External Javascript File

Jan 8, 2011

I have a web user control. That I load dynamicaly inside a modalpopup window using dynamic populate extender. User control has a external javascript file linked to it. Problem: I cannot make call to webservice method from this external javascript file. When I make a call -- servicename.methodname() I get servicename not defined error.

View 2 Replies

WCF / ASMX :: Call A Webservice On A Site That Requires Authentication?

Mar 3, 2011

I have a production web application that uses <authentication mode="Windows"/> I have added an .asmx page with a method in it. I'd like to test making calls to it from a separate client web app. When I do this I get the error: The request failed with HTTP status 401: Access Denied What do I need to do in my client app to access this webservice?

View 2 Replies

Security :: Event Viewer Information Message / Forms Authentication Failed For The Reques

Aug 18, 2010

I've made a for a web app to use sql server session state, in the event viewer I get a re-occuring informatation message:

Event code: 4005

Event message: Forms authentication failed for the request. Reason: The ticket supplied has expired.

Event time: 17/08/2010 10:37:01
Event time (UTC): 17/08/2010 09:37:01
Event ID: 623a3b87c23541b9b8b49d9a9a167bde
Event sequence: 7699
Event occurrence: 124
Event detail code: 50202

Process information:
Process ID: 10188
Process name: w3wp.exe
Account name: NT AUTHORITYNETWORK SERVICE

User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITYNETWORK SERVICE

It dosnt seem to be causing any problems, just filling the event viewer...

View 3 Replies

How To Throw And Catch Exception Handling

Oct 12, 2010

iam inserting record in three tables in a database, iam using begin trans , commit transaction and rollback,

i want to use throw method, if any value insert wrong, pls correct me, i want to throw the error and

its go to rollback

running = false;
int updaterec = DBmgr.ExecuteNonQuery(CommandType.Text, "update ASArrivedcontainer set billgen ='Y' where billgen ='y' and acontinerid in ("+SelValues+")");
if (updaterec > 0)
{
running = true;
DataSet BillContainerDetails = BillingDetails();
byte[] ContainerDetails = GenerateBill(DBmgr, sContainerIds, rcno,isGeneralRCNo, FetchContainerDetails, ModifyId,ref BillContainerDetails);
DBmgr.CreateParameters(6);
//string otherchargesId = obj.retriveSingleRecord("select top(1) ModifyId from ASOtherCharges");
DBmgr.AddParameters(0, "@InvoiceNo", "1","IN");
DBmgr.AddParameters(1, "@BillDate", DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss tt"), "IN");
DBmgr.AddParameters(2, "@CustomerId", "1", "IN");
DBmgr.AddParameters(3, "@TotalAmount", "10000", "IN");
DBmgr.AddParameters(4, "@OtherChargesId", ModifyId, "IN");
DBmgr.AddParameters(5, "@ContainerDetails", ContainerDetails, "IN");
String BillNo = DBmgr.ExecuteScalar (CommandType.Text, "Insert into BillMaster(InvoiveNo,BillDate,CustomerId,TotalAmount,OtherChargesId,ContainerDetails) values (@InvoiceNo,@BillDate,@CustomerId,@TotalAmount,@OtherChargesId,@ContainerDetails)
Select @@Identity ").ToString();
if (!String.IsNullOrEmpty(BillNo))
{
running = true;
DBmgr.CreateParameters(4);
for (int i = 0; i < BillContainerDetails.Tables[0].Rows.Count; i++)
{
BillContainerDetails.Tables[0].Rows[i]["BillNo"] = BillNo;
DBmgr.AddParameters(0, "@Billno", BillContainerDetails.Tables[0].Rows[i].ItemArray[1].ToString(), "IN");
DBmgr.AddParameters(1, "@rcno", BillContainerDetails.Tables[0].Rows[i].ItemArray[2].ToString(), "IN");
DBmgr.AddParameters(2, "@acontinerid", BillContainerDetails.Tables[0].Rows[i].ItemArray[3].ToString(), "IN");
DBmgr.AddParameters(3, "@bflag", BillContainerDetails.Tables[0].Rows[i].ItemArray[4].ToString(), "IN");
//string value = BillContainerDetails.Tables[0].Rows[i].ItemArray[0].ToString(); ;
// string strsql = "insert into billcontinerdetail(billno,rcno,acontinerid,bflag) values(@billno,@rcno,@acontinerid,@bflag)";
String count = DBmgr.ExecuteScalar(CommandType.Text, "insert into billcontinerdetail(billno,rcno,acontinerid,bflag) values(@billno,@rcno,@acontinerid,@bflag)Select @@Identity").ToString();
if (count > 1)
{
running = true;
}
else
{
}
//running = true ;
//break;
}
DBmgr.CreateParameters(6);
for (int j = 0; j < BillContainerDetails.Tables[1].Rows.Count; j++)
{
DBmgr.AddParameters(0, "@billcontkey", BillContainerDetails.Tables[1].Rows[j].ItemArray[1].ToString(), "IN");
DBmgr.AddParameters(1, "@ratetypcode", BillContainerDetails.Tables[1].Rows[j].ItemArray[2].ToString(), "IN");
DBmgr.AddParameters(2, "@days", BillContainerDetails.Tables[1].Rows[j].ItemArray[3].ToString(), "IN");
DBmgr.AddParameters(3, "@amount", BillContainerDetails.Tables[1].Rows[j].ItemArray[4].ToString(), "IN");
DBmgr.AddParameters(4, "@level", BillContainerDetails.Tables[1].Rows[j].ItemArray[5].ToString(), "IN");
DBmgr.AddParameters(5, "@sflag", BillContainerDetails.Tables[1].Rows[j].ItemArray[6].ToString(), "IN");
// string strsql = "insert into billratedetail(billcontkey,ratetypcode,days,amount,level,sflag)values(@billcontkey,@ratetypcode,@days,@amount,@level,@sflag)";
String count = DBmgr.ExecuteScalar(CommandType.Text, "insert into billratedetail(billcontkey,ratetypcode,days,amount,level,sflag)values(@billcontkey,@ratetypcode,@days,@amount,@level,@sflag)Select @@identity ").ToString()
;

View 2 Replies

Call Web Methods Of WebService In Javascript

Nov 5, 2010

I'm doing a project in asp.net with a web services. My web services and my asp.net project is separate and my asp.net projet have a reference of my web services. i'm using visual studio 2008 framework 3.5 and my service web is in vb.net. i want to call the web methods of my web services in javascript my script manager is declared

<asp:ScriptManager runat="server" ID="scriptManager" EnablePageMethods="true" >
<Services>
<asp:ServiceReference path="http://localhost:2931/ServiceCompas.asmx"/>
</Services>
</asp:ScriptManager>
the javascript fuctions
<script type="text/javascript">
function test() {
alert('test');
Service1.Liste_Carte(Onsucced);
}
function Onsucced(resultat) {
alert('je suis passée');
}
</script>

service1 is the class of my Webservice and i call the function test with my button <input name="btnRecherche" class="btnRechercher" type="button" value="Rechercher un emplacement" onclick="test()" /> the problem is : JavaScript say Service1 is not defined but why .... What's the problem ? I've checked many forums and videos every body did it
sorry for the french variable

View 3 Replies

Set Dynamic Controls So It Doesn't Throw Exception

Jun 28, 2010

I have problem with Dynamic Controls in my Wizard Steps. In one of my Steps, I create a set of text boxes and checkboxes based on values from an XML document. Now, I initialise my dynamic controls using the OnInit method of the page, but at this stage there is no xml document until that step is reached, and of course I get null exception. How do I set my dynamic controls so it doesn't throw an null exception and be able to load any xml document when that step is reached?

View 1 Replies

WCF / ASMX :: Call Webservice Hosted On IIS From Javascript?

Jan 11, 2011

all My web app is calling webservice which resides in same virtuall directory as web app . In this scenario i have a javascript function like this which works perfectly.

[Code]....

View 2 Replies

Kill A Javascript Async Call To A .net Webservice?

Jun 14, 2010

My javascript code is calling a asp.net webservice, so i have a call to the webservice something like this:MyWebservice.GetData(param, ResponseReceived, ResponseTimeOut, ResponseError);When the webservice returns data, ResponseReceived method is called.However sometimes the user might navigate to another url before the webservice call actually returns, in such a scenario FireFox throws an Error saying 'An error occured oricessubg the request. The server method GetData failed'So my question is how can i kill the async call when the user navigates to another page or makes another request to the webservice? I know in a normal XMLHttpRequest i could have called Abort method, but not sure how to make it work with the above webservice proxy.

View 2 Replies

Global.Asax - When Click On Datagrid Throw Exception

Nov 4, 2010

I m having a datagrid and for client side events I m using Javascript. I have few other buttons in the same page.

when I click on datagrid and select, it is working fine. After that, if I click on any other button in the Page, It is directly going to global.asax and throwing exception.

If I click directly on other buttons, they are working fine. Once I click on Datagrid and try to click on other buttons, it is throwing that exception.

View 2 Replies

How To Throw Exception If Session Is Written To In ReadOnly Mode

Sep 3, 2010

I would like to find a way to raise an exception if the Session is written to when in readonly mode. When EnableSessionState is set to "ReadOnly", values can still be put in Session, but the next request they will not be there. This seems somewhat dangerous.

One option is to create a helper class which we alway use to access session. However, this still leaves room for a developer to inadvertently use session directly, and fall into the "readonly" trap. Is there a way to create a CustomSessionStateDataStore that sits on top of the existing session code? I could not see an obvious way, and you can't inherit from System.Web.SessionState.SessionStateStoreData directly.

View 2 Replies

C# - Dynamicdata Validation Exception Message Caught In JavaScript, Not DynamicValidator

Feb 12, 2010

I have a page here with a few list views on it that are all bound to Linq data sources and they seem to be working just fine.I want to add validation such that when a checkbox (IsVoid on the object) is checked, comments must be entered (VoidedComments on the object).

Here's the bound object's OnValidate method:

partial void OnValidate(ChangeAction action)
{
if (action == ChangeAction.Update) [code]....

Despite there being a dynamic validator on the page referencing the same ValidationGroup as the dynamic control, when the exception fires, it's caught in JavaScript and the debugger wants to break in. The message is never delivered to the UI as expected.

View 2 Replies

DataSource Controls :: EntityDataSource Throw Exception When Update With Self-Reference?

Nov 3, 2010

For a Table A defined in the DB like this:

A :{ id, selfId, name,} where selfId is a foreign key refered to Table A itself.

I generated the Entity automatically like this:

A :{ string id; A self; string name,} when i update the entity in gridview Edit/Update CommandField

i got the exception:

Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error:

[Code]....

Stack Trace:

[Code]....

I guess maybe this is caused by:

A is to be updated, and when the EntityDataSource construct the new A, the reference "self" is invalid at that moment. I do not want to modify my DB structure and do not want to lose the self reference, The event EntityDataSource_Updating is not triggered while the exception hit. so i can not access my entity at any time. Maybe the worst idea is deal the whole Update Procedure myself. However, is there any better workaround?

View 3 Replies

AJAX :: Custom Exception Handling In Webservice?

Jan 13, 2010

I am trying to write a webservice that's going to be used through ASP.Net Ajax. In this webservice I have to add exception handling so that in case of any error, I could log them to some central place and then throw.

In my other areas of code (like aspx pages), i have been using a basepage which Overrides System.Web.UI.Page class's OnError by adding a custom event handler. I want to do the same for my webservice as well.

Basically I do not want to decorate each webservice method with a Try Catch block. Instead if there is a clean way like to override the on error method, i want to go for that. Unfortunately the WebService class does not seem to have any functionality for this.

View 2 Replies

Javascript - Prevent Submit And Call A Webservice On Enter Keypressed In A Textbox?

Mar 21, 2011

Is there a simple way to turn off form submit behaviour of the page when ENTER is pressed while I am focused to textbox? What I want to achieve is to call a web-service without submiting the page when ENTER is pressed in a specific textbox in my aspx page?

View 1 Replies

WCF / ASMX :: Throw A Custom Message From A Web Service

Jun 24, 2010

I have a schema which contains the ErrorCode and ErrorDescription.

When error is captured i need to create a new xml and throw it to the client with the error code and description captured from the client

View 1 Replies

Web Forms :: DataSet.Fill Takes Along Time To Throw Exception When Connectionstring Wrong

Jan 18, 2010

when my website allow user many connectionstring by text to connect database anh retrieve data. But when user define very may wrong connectionstring. So Method in DAL dataset.Fill() takes a longtime to throw exception.So mywebsite will be die.

I want to method dataset.Fill() throws exception immediately when a connectionstring wrong. How can i do that?

View 2 Replies

AJAX :: Pagemethod Authentication Failed?

Mar 3, 2011

I have a page that requires user login via Forms Authentication. Is it possible to use Page Methods in this page? My current attempt is resulting in the following error:Message: Sys.Net.WebServiceFailedException: The server method 'GetPlanContent' failed with the following error: System.InvalidOperationException-- Authentication failed.

View 2 Replies

AJAX :: AutoComeple Does Not Call Webservice?

Feb 17, 2011

I have am trying to implement a simple AutoComplete function yet i am having difficulty. It looks like the AutoComplete control is not even calling the method (webservice). If i load the webservice from the browser, i can see my Method, click on it, enter in the prefix, click on Invoke and it returns a SQL STRING. Below is the string the webservice returns.

<?xml version="1.0" encoding="utf-8"
?>

View 4 Replies

Forms Data Controls :: Throw The Exception Back To Page_Load Error: ArgumentNullException Was Unhandled By User Code

Nov 19, 2010

I'm trying to throw the exception back to Page_Load but the throw statement causes error: ArgumentNullException was unhandled by user code. How can that be fixed? Also, I can't see Label1.Text displayed on the page after the ArgumentNullException occurs because the page is not re-load. If there is no exception, it's fine to not reload the page. How can I see the Label1.Text displayed?

protected void Page_Load(object sender, EventArgs e)
{
try
{
...do something here...
}
catch (ArgumentNullException ae)
{
System.Diagnostics.Debug.Write(ae.Message);
Label1.Text = ae.Message;
Label1.Style.Add("visibility", "visible");
}
catch (Exception ex)
{
...do something here...
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)............................

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved