|
I'm trying to write a simple javascript script that will enable the web page to send commands to my proxy server that I'm developing.
However it appears that both Firefox and IE block any attempt to use the XMLHttpRequest object to send web requests.
Is there ANY way I can get javascript to send ANY kind of information over the wire that my proxy server can intercept and provide custom services?
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
I don't completely understand, are you saying that IE and Firefox aren't letting you make Ajax calls?
The XMLHttpRequest does send web requests.
In addition what sort of proxy are you using?
Brad
Australian
By contacting your lawyer you negate the right to sue me.
|
|
|
|
|
Hi Brad,
I wrote a simple script that calls open( "GET", url, true ); and the Error Console in Firefox says, "Permission denied to call method XMHttpRequest.open"
The proxy is something I'm developing. It's going to be an intercepting proxy.
In the code below, the alert( "Request sent" ) never gets called:
var xmlhttp;
function loadPage( url )
{
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
alert( "Request Sent" );
}
function state_Change()
{
alert("State Change" );
if (xmlhttp.readyState==4)
{
if (xmlhttp.status==200)
{
alert( "200 OK!" );
}
else
{
alert("Problem retrieving XML data");
}
}
}
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
Can you post all the javascript that relates to the request here?
Brad
Australian
By contacting your lawyer you negate the right to sue me.
|
|
|
|
|
I'm just beginning to learn javascript, so the code I'm trying to use is very simple: ( Thanks for your help ) It says "window.removed" below, but that's something CodeProject did. The real code says "onload"
<script language = "javascript" >
<!--
function myonload( )
{
loadDoc( "http://www.google.com" );
}
window.onload = myonload;
var xmlhttp;
function state_Change()
{
alert("State Change" );
if (xmlhttp.readyState==4)
{
if (xmlhttp.status==200)
{
alert( "200 OK!" );
}
else
{
alert("Problem retrieving XML data");
}
}
}
function loadDoc( url )
{
xmlhttp=new XMLHttpRequest();
xmlhttp.removed=state_Change;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
alert( "Request Sent" );
}
</script>
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
|
That's OK, thanks for your participation anyway.
I will take a look at that link and see if it can provide some clues.
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
Brad, your link DID provide the answer. It turns out that you're not allowed to make requests to domains other than the one that the page belongs to.
So because I was requesting Google, it gave the permission denied error.
Thanks!
--------------------------------
"All that is necessary for the forces of evil to win in the world is for enough good men to do nothing" -- Edmund Burke
|
|
|
|
|
That must be new to FF. No problem btw.
Thanks for asking the question, I could have seen myself making the same mistake.
BTW a quick hack to get past this is to build PHP/ASP application that will call the requested page, and have that uploaded to ur server.
Brad
Australian
By contacting your lawyer you negate the right to sue me.
|
|
|
|
|
Richie308 wrote: It turns out that you're not allowed to make requests to domains other than the one that the page belongs to.
Much as it pains me to admit it, apparently ATLAS provides a way around this.
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Richie308 wrote: It turns out that you're not allowed to make requests to domains other than the one that the page belongs to.
It would be a huge security hole otherwise. There are ways of getting around this for most browsers, but they require the user to explicitly allow the exception - so, they're more useful for intranet-type development.
|
|
|
|
|
Hello,
I was wondering 'if this is even possible' what is the "right" way to perform caching and state management within WebServices with ASP.Net 2.0? Or should you just use System.IO.MemoryStream?
My Scenario is:
UI will hit WebService lets say every 10 min and request data. However I don't want every user hitting the WebService to make a call to SQL.
Just need to be pointed in the right direction.
Thank you for the help.
RB
|
|
|
|
|
While State Management IS supported, it's generally not a recommended practice to implement it with web services due to scalability and practical reasons. Also you need to make sure that whatever is calling it also supports state management, typically via HTTP Cookies.
You implement it like this...
[WebMethod(EnableSession=true)]<br />
public Object DoSomething(){}
Then, providing you're deriving from System.Web.Services.WebService, you use Session same way you use it in ASP.NET web pages. However, if the caller doesn't support stateful webservice, then the Session values will be emptied with every call. If the caller is also a .NET app then enabling stateful Web Service support is entirely possible, write back and I'll post some code.
As for Caching, yes this is possible and recommended. You could do this manually using the Cache property of System.Web.Services.WebService (same way as ASP.NET web pages), or get the WebService to handle Caching itself like this...
[WebMethod(CacheDuration=600)]<br />
public Object DoSomething(){}
This will cache the output of the web service for 10 minutes (600 seconds). It's also intelligent enough to detect input parameters in the WebMethod and Cache different outputs depending on the input params. Although if lots a input params are used, you could end up caching lots of data and flooding the servers memory, so be careful.
|
|
|
|
|
Thank you very much for the information. Very helpful.
|
|
|
|
|
I am student of final year engineering student. I selected “SMS Website” as my project topic. In this I have to send Bulk SMS through website and provide other kind of services related to SMS.
Please tell me which steps I should follow.
Please send me some material or any kind of source code related to it.
I need your help.
Thank you!!!
Contact Me: ashish.0619@gmail.com
|
|
|
|
|
Hello mate.
I can tell you that there is an article somewhere in CP about this very topic. I can't remember its name however.
Basically you have to use an smpt mail server and send it to the phone companies mail server.
look for the article.
Brad
Australian
By contacting your lawyer you negate the right to sue me.
|
|
|
|
|
|
I have a popup date-picker in my asp.net application...
..trouble is, ie7 seems to abandon the session whenever the popup window is closed.
tried this in a couple of apps, with different popups. Seems to be a serious bug in ie7. Is it, or is it me...?
cheers
Fred
|
|
|
|
|
IIS/ASP.NET has cookless and cookie-based session state. If the session state is based on cookies and a pop-up appears, it is possible the session cookie is being altered by a 3rd party application (spam/virus). Web servers (e.g. IIS) usually control the duration of a session unless it is told to abandon the session on the server-side. IE7 does not control session duration.
Geo
|
|
|
|
|
Thanks - I know the theory, but I'm telling you it happens: on three different apps on two different servers, on closing a popup window session state is lost when using IE7.
I would be interested to know yours or anyone's experience (as opposed to theory) about this - are you using IE7, and have you encountered this too?
cheers
Fred
|
|
|
|
|
I use IE7. It has never happened to me but I don't allow those annoying pop ups.
|
|
|
|
|
OK, look I'm really sorry if I'm being dense here, but i don't hink so... And it's not just popups, but even pages openeed in a new tab or window (eg target="_blank")
Try this page in if you don't believe me:
http://www.psu-tests.co.uk/a.aspx
try it in IE7 and then in Firefox...
the complete code is shown below:
First page (a.aspx) sets a session variable Session("ok") = "abc"
first link opens a new window (b.aspx) and prints out the value of Session("ok")
close it, and then click second link which opens c.aspx in same tab, and this also (tries to) print out Sesion("ok") - but in IE7 it can't because it's been lost....
What is going on?
a.aspx
------
<%@ Page Language="vb" debug="true" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Session("ok") = "abc"
End Sub
</script>
<HTML>
<HEAD>
<title></title>
</HEAD>
<body >
<form id="Form1" method="post" runat="server">
<a href="b.aspx" target="_blank">click me</a>
<br />then, after closing that window,
<a href="c.aspx">click me</a>
</form>
</body>
</HTML>
b.aspx
------
<%@ Page Language="vb" debug="true" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Label1.Text = Session("ok")
End Sub
</script>
<HTML>
<HEAD>
<title></title>
</HEAD>
<body >
<form id="Form1" method="post" runat="server">
<input name="btn" type="button" value="Close me" onclick="self.close()" />
<br />
<asp:label runat="server" ID="Label1"></asp:label>
</form>
</body>
</HTML>
c.aspx
------
<%@ Page Language="vb" debug="true" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Label1.Text = Session("ok")
End Sub
</script>
<HTML>
<HEAD>
<title></title>
</HEAD>
<body >
<form id="Form1" method="post" runat="server">
<a href="a.aspx">back</a>
<br />
<asp:label runat="server" ID="Label1"></asp:label>
</form>
</body>
</HTML>
|
|
|
|
|
Now it's working. Forget it, I'll just go shoot myself. I have no idea what's going on.
fred
|
|
|
|
|
I can't be 100% sure, but I'm pretty sure IE6 treats different windows as different independent sessions, whereas Firefox and Opera will combine sessions if you, say, have the same website open in different windows. In IE it's possible to have two windows both opened at amazon.com but be logged in as two different users.
Now if this is the case with IE6 it will probably the case with IE7, and right click opening a new window will probably start a new session. Dunno if this helps at all.
|
|
|
|
|
thanks - I've never had this problem with IE6, but am having to re-write all my popup date-pickers in order to cope with IE7 (at least, on those sites that rely on session-state.)
Possibly neater anyway, having them inline and using AJAX when necessary, but I could do without the extra work. I'm sure I can't be the only one experiencing such difficulties though, and I find it puzzling I haven't seen more about this elsewhere. There's nothing peculiar about my code - just a simple window.open js call....
ah well..
cheers
Fred
|
|
|
|