[OpenLayers-Users] Authentication Error

Christian López Espínola penyaskito at gmail.com
Fri May 30 11:42:06 EDT 2008


Hi,

Please note that not all the readers here are familiar with the usual
ASP.NET jargon.

It seems to me that this is an ASP.NET problem with authentication,
not an OL one.
I've seen that you posted here: http://forums.asp.net/t/1257016.aspx
and that's the better place for asking.

I can try to help you, but this should be offlist because it's not
OpenLayers related, and I would require a minimal demo (code) that
shows the problem.
Don't hesitate to contact me offlist.

HTH


On Fri, May 30, 2008 at 5:24 PM, Lee Keel <lee_keel at trimble.com> wrote:
> 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: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
> Behalf Of Lee Keel
> Sent: Wednesday, May 28, 2008 11:22 AM
> To: users at openlayers.org
> 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
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>



-- 
Cheers,

Christian López Espínola <penyaskito>


More information about the Users mailing list