<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CORS policy issue in .NET CORE in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cors-policy-issue-in-net-core/m-p/211934#M19599</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually figured out my issue, so I'll be posting here and maybe it'll help someone out in the future.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue with the CORS policy was that I was doing an $.ajax call and not specifying that the datatype is in JSON format. The browser doesn't like that, so the lack of datatype is considered a security risk by the browser and it blocks it. I did lose quite a bit of time to solve this but at least it's resolved.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jun 2020 18:16:56 GMT</pubDate>
    <dc:creator>NovicaJosifovski</dc:creator>
    <dc:date>2020-06-23T18:16:56Z</dc:date>
    <item>
      <title>CORS policy issue in .NET CORE</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cors-policy-issue-in-net-core/m-p/211933#M19598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #242729; background-color: #f9f8f6; border: 0px; margin: 0px 0px 1em;"&gt;So I have a .net core app which currently throws an error in console saying:&lt;/P&gt;&lt;P style="color: #242729; background-color: #f9f8f6; border: 0px; margin: 0px 0px 1em;"&gt;&lt;SPAN&gt;Access to XMLHttpRequest at '&lt;A href="https://app.test.mk/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer?f=json&amp;amp;dpi=96&amp;amp;transparent=true&amp;amp;format=png8" target="_blank"&gt;https://app.test.mk/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer?f=json&amp;amp;dpi=96&amp;amp;transparent=true&amp;amp;format=png8&lt;/A&gt;' from origin '&lt;A href="https://localhost:44348" target="_blank"&gt;https://localhost:44348&lt;/A&gt;' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '&lt;A href="https://localhost:44348" target="_blank"&gt;https://localhost:44348&lt;/A&gt;, *', but only one is allowed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="color: #242729; background-color: #f9f8f6; border: 0px; margin: 0px 0px 1em;"&gt;&lt;/P&gt;&lt;P style="background-color: #f9f8f6; border: 0px; margin: 0px 0px 1em;"&gt;and this is what my Startup file looks like:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; public void ConfigureServices(IServiceCollection services)
 {
 services.AddCors(o =&amp;gt; o.AddDefaultPolicy(builder =&amp;gt;
 {
 builder
 .WithOrigins("https://localhost:44348/", "https://app.gdi.mk/arcgis/rest/info?f=json",
 "Access-Control-Allow-Origin", "Access-Control-Allow-Credentials")
 .AllowAnyOrigin()
 .AllowAnyMethod()
 .AllowAnyHeader();
 }));
 services.AddControllersWithViews();
 services.AddRazorPages().AddNewtonsoftJson();
}

 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
 {
 if (env.IsDevelopment())
 {
 app.UseDeveloperExceptionPage();
 }
 else
 {
 app.UseExceptionHandler("/Home/Error");
 // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
 app.UseHsts();
 }
 app.UseCors();

 app.UseHttpsRedirection();
 
 app.UseStaticFiles();

 app.UseRouting();

 app.UseAuthorization();

 app.UseEndpoints(endpoints =&amp;gt;
 {
 endpoints.MapControllerRoute(
 name: "default",
 pattern: "{controller=Home}/{action=Index}/{id?}");
 });

 }
 }&lt;CODE&gt;&lt;SPAN class="" style="color: var(--blue-800); border: 0px; font-weight: inherit; font-size: 13px; margin: 0px;"&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #242729; background-color: #f9f8f6; border: 0px; margin: 0px 0px 1em;"&gt;and this is at the top of my View, in a script tag.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-weight: inherit; background-color: #f9f8f6; color: #242729; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;require(["esri/config"], function (esriConfig) {

 esriConfig.defaults.io.corsEnabledServers.push("http://app.test.mk");
 esriConfig.defaults.io.corsEnabledServers.push("https://localhost:44348/");
 // esriConfig.defaults.io.corsEnabledServers.push("http://app.test.mk/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer");
 // esriConfig.defaults.io.corsEnabledServers.push("https://app.test.mk/arcgis/rest/services/karpos/Karpos_Vector_Izvodi/MapServer?f=json&amp;amp;dpi=96&amp;amp;transparent=true&amp;amp;format=png8");

 });

Anyone has any idea what the problem could be? I've been trying things for two days and the app keeps throwing the same error.&amp;nbsp;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:25:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cors-policy-issue-in-net-core/m-p/211933#M19598</guid>
      <dc:creator>NovicaJosifovski</dc:creator>
      <dc:date>2021-12-11T10:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: CORS policy issue in .NET CORE</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cors-policy-issue-in-net-core/m-p/211934#M19599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I actually figured out my issue, so I'll be posting here and maybe it'll help someone out in the future.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue with the CORS policy was that I was doing an $.ajax call and not specifying that the datatype is in JSON format. The browser doesn't like that, so the lack of datatype is considered a security risk by the browser and it blocks it. I did lose quite a bit of time to solve this but at least it's resolved.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 18:16:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cors-policy-issue-in-net-core/m-p/211934#M19599</guid>
      <dc:creator>NovicaJosifovski</dc:creator>
      <dc:date>2020-06-23T18:16:56Z</dc:date>
    </item>
  </channel>
</rss>

