Hi Phillip,
Thank you for your code. I've done some test locally and found out it's not
an issue related to the ActiveX Control, but to the fact that currently
WebTest cannot record AJAX calls from the web page.
Here's my test steps and a workaround to fix this issue:
1) Create an AJAX enabled WebSite
2) Add a WebService:
<%@ WebService Language="C#" Class="WebService" %>
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
[WebService(Namespace = "
http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class WebService : System.Web.Services.WebService {
[WebMethod()]
public string HelloWorld() {
return "Hello World";
}
[SoapDocumentMethod(OneWay=true)]
[WebMethod(EnableSession=true)]
public void SetSessionState(string name, object value) {
Session[name] = value;
}
[WebMethod(EnableSession=true)]
public object GetSessionState(string name) {
return Session[name];
}
}
3) Add a WebForm:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Session["foo"] != null)
{
Label1.Text = Session["foo"] as string;
}
}
</script>
<html xmlns="
http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function HelloWorldCallback(result)
{
document.getElementById("result").innerHTML = result;
}
function GetSessionStateCallback(result)
{
document.getElementById("result").innerHTML = result;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="WebService.asmx" />
</Services>
</asp:ScriptManager>
<div id="result">Result</div>
<input type="button"
onclick="WebService.HelloWorld(HelloWorldCallback)" value="Hello World" />
<input type="button" onclick="WebService.SetSessionState('foo',
'bar')" value="SetSessionState" />
<input type="button" onclick="WebService.GetSessionState('foo',
GetSessionStateCallback)" value="GetSessionState" />
<asp:Button ID="Button1" runat="server" Text="PostBack"
OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body>
</html>
4) Test Default.aspx in IE, after you click button "SetSessionState", click
on button "PostBack" and verify the session state variable 'foo' set in
WebService can be read by WebForm.
5) Now create Test project and add a WebTest to record a test: click button
"SetSessionState", click button "PostBack"
6) If you now run the WebTest in Visual Studio, at the end, the session
state variable 'foo' doesn't get retrieved back successfully since it's
actually not set at all.
Now the workaround:
1) Install latest version of Fiddler (
http://www.fiddlertool.com/)
2) Launch Fiddler before recording the WebTest
3) After you finished recording, find the "session" (don't confuse this
with ASP.NET session, it's a session in Fiddler's "Web Sessions" window) in
fiddler that represents the Ajax call (requesting WebService.asmx),
right-click on it and select menu "Save/Session/as Visual Studio WebTest".
4) In your Visual Studio test project, add this saved webtest and open it,
then copy the request and paste into your previously recorded webtest, make
sure you order the requests correctly.
5) Now re-run the webtest, in the end, it should correctly display the
session state variable's value.
I hope I haven't misunderstood anything, since I didn't encounter the
ActiveX Control security warning as you described previously.
Regards,
Walter Wang (
[email protected], remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.