I did not get many replies to this, so I thought I would elaborate a
little more and explain why I asked this question on this forum.
 
I have a map that I have on a page that is on a secure website using
forms authentication.  When the user clicks on the map, I want to send
the coordinates, visible layers, and resolution back to the server so
that I can perform a database query.  I was doing this by using an AJAX
call to a WebMethod on my page which would set these values in session
variables, then I would call refresh on an updatepanel and then perform
some work with the session variables.  Before I implemented security,
this was working just fine, but now that I have security turned on for
this page I get an Authentication Error whenever I try to make my
PageMethod call.
 
So here is some code that was working before security was enabled:
javascript:
click: function (evt) {
    OpenLayers.Console.dir(evt);
    var layers = [];

    for (var i = 0; i < map.layers.length; i++){
        if (map.layers[i].visibility == true && map.layers[i].inRange ==
true ){
            layers.push(map.layers[i].name);
        }
    }

    var lonlat = map.getLonLatFromPixel(evt.xy);
    var resolution = map.getResolution();

    PageMethods.SearchPoint(lonlat.lon, lonlat.lat, resolution, layers,
SearchPointSuccess, SearchPointFailure);
    Event.stop(evt); 

},

function SearchPointSuccess(args) {
    __doPostBack('<%= udpTabs.ClientID %>', '');
}

C#:
[WebMethod(EnableSession = true)]
public static void SearchPoint(double X, double Y, double resolution,
string[] layers){
    HttpContext.Current.Session["X"] = X;
    HttpContext.Current.Session["Y"] = Y;
    HttpContext.Current.Session["resolution"] = resolution;
    HttpContext.Current.Session["layers"] = layers;
    HttpContext.Current.Session["searchtype"] = "IdentifyPoint";
    HttpContext.Current.Session["srid"] =
ConfigurationManager.AppSettings["srid"];
}

protected void Page_Load(object sender, EventArgs e){
    if(this.IsPostBack)
    {
        //Get session variables and do work
    }
}

 
Does anyone have a better way to send information from the client back
to the server?  Or at this point I would even settle for a way that
works with security on.  My only thought right now is to put these
values into a hidden field and when the refresh is performed I could
parse the information from the text.  But it just seemed to me that the
AJAX call was much cleaner and more secure.

Thanks in advance,
Lee
 
________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Lee Keel
Sent: Wednesday, May 28, 2008 11:22 AM
To: [email protected]
Subject: [OpenLayers-Users] Authentication Error


Hello All,
 
I have been trying to implement forms authentication on my website and
have run into a little snag.  I know this is not directly an OpenLayers
question, but there are so many smart javascript programmers on here, I
am hoping for an answer.
 
The problem is that now that I have security enabled I am having a
problem making calls from my javascript back to my webmethods using the
PageMethod calls.  When ever I make a PageMethod call, I get a 401 -
"Authentication Failed".  Has anyone experienced this before?  If so,
could you please give me some idea on how you fixed it?
 
Best Regards,
Lee Keel

<<Blank Bkgrd.gif>>

_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to