Friday, 8 January 2016

openlayers - Access-Control-Allow-Origin in geoserver and ol3


I am using OL3, Geoserver. I made a website with Asp.net and add map with OL3. which is get data from geoserver with WFS. my website is located in C:\programfile\geoserver\www\mysite. Also config IIS that when client (with IP 192.168.0.100) clicl IP of server, it will show the website. (server IP is 192.168.0.1) the problem is that I receive this error.


XMLHttpRequest cannot load http://localhost:8000/geoserver/cite/ows?service=WFS&version=1.0.0&request=…e&typeName=cite:MyFeature&maxFeatures=50&outputFormat=application/json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.0.100' is therefore not allowed access. 

how can I config IIS and Geoserver that solve this problem?




Answer



I tried a lot to config IIS ARR reverse proxy but unfortunately it was not useful for me. Also using CORS is not good idea because some of the browsers don't support it. So I became to write a proxy in asp.net by Generic handler. create proxy.ASHX file. then pass the url to this file. like:


url = "proxy.ashx?url=http://localhost:8080/geoserver/wfs/...."

then use WebRequest to send my request and get the response by HttpWebResponse and send it back to my website.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...