Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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: ""


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 ?

share|improve this question

marked as duplicate by iant, Devdatta Tengshe, Aragon, Zachary, R.K. Feb 17 '13 at 15:58

This question was marked as an exact duplicate of an existing question.

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.

share|improve this answer
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 <…; – Tommaso Feb 11 '13 at 15:57

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