I use OpenLyaers in order to show france Departements. My website is generated in ASP .NET MVC 4 (i use Visual studio 2012) ans i use GeoServer to store WFS files.

I want to access to my WFS layer by

var wfs =  new OpenLayers.Layer.Vector("States", {
            strategies: [new OpenLayers.Strategy.BBOX()],
            protocol: new OpenLayers.Protocol.WFS({
                url: "http://localhost:8080/geoserver/wms",
                featureType: "states",
                featureNS: "http://www.openplans.org/topp"


In Google Chrome console i have :

XMLHttpRequest cannot load http://localhost:8080/geoserver/wms. Origin http://localhost:50431 is not allowed by Access-Control-Allow-Origin. 

How i can parametre Geoserver to solve this problem ?


you are trying to do some cross-domain request, qhich are denied by default as defined by the Same origin Policy. There are 2 solutions:

  1. For debug only, you can start chrome with the option:

    chrome.exe --disable-web-security

  2. The modern browser allow cross-domain ajax if the server add a particular header in the response. Now it depends under which server Geoserver is running. If it's jetty, you can allow cross-domain as described in the Jetty wiki.

  • Thank you for your answer. Geoserver run with jetty (i have Geoserver 2.4 installed with windows installer). I did what it is explained in the jetty Wiki but Now i have this mistake when i want to open the geoserver page : HTTP ERROR: 503 SERVICE_UNAVAILABLE RequestURI=/geoserver/web/ Powered by jetty:// Maybe i havent' get the good jetty-servlets.jar in the good directory. How i can know which choose and where place it ? – ROCHEDY Feb 11 '13 at 15:26
  • @ROCHEDY try this link <gis.stackexchange.com/questions/32407/…> – Tommaso Feb 11 '13 at 15:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.