Enable CORS not working

2 posts, 0 answers
  1. Jennifer
    Jennifer avatar
    18 posts
    Member since:
    Aug 2011

    Posted 31 Aug 2018 Link to this post

    I know this question has been posed several times and I have read the solutions and watched the instructional video provided but it is still not working for me.  I must be missing something and am hoping someone can point it out.  Works fine in development when everything is on my machine but when I move the Reporting Service to the server and launch my Angular project with a service url pointing to the Reporting Service on the server, it gives the following error:

    Error loading the report viewer's templates. (Template = http://myhost/ReportingSample/api/reports/resources/templates/telerikReportViewerTemplate-html).

    and this error in the console: Origin http://localhost:4200 not found in Access-Control-Allow-Origin header. (along with other CORS related errors).

     

     

    I have the following in my Global.asax.vb:

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)<br>        System.Web.Http.GlobalConfiguration.Configuration.EnableCors<br>        Telerik.Reporting.Services.WebApi.ReportsControllerConfiguration.RegisterRoutes(System.Web.Http.GlobalConfiguration.Configuration)<br>        ' Fires when the application is started<br>    End Sub

     

    Controller:

    Namespace Controllers<br>    <br>    <EnableCors("*", "*", "*", "*")><br>    Public Class ReportsController<br>        Inherits ReportsControllerBase<br>        Shared configurationInstance As Telerik.Reporting.Services.ReportServiceConfiguration...

     

    Web.config:

    <runtime>
       <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
           <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="8fb06cb64d019a17" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-2.8.1.0" newVersion="2.8.1.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
           <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="31BF3856AD364E35" />
           <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.1.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Net.Http.WebRequest" culture="neutral" publicKeyToken="31BF3856AD364E35" />
           <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.0.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Net.Http.Formatting" culture="neutral" publicKeyToken="31BF3856AD364E35" />
           <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.2.6.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Web.Http" culture="neutral" publicKeyToken="31BF3856AD364E35" />
           <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.2.6.0" />
         </dependentAssembly>
         <dependentAssembly>
           <assemblyIdentity name="System.Web.Http.WebHost" culture="neutral" publicKeyToken="31BF3856AD364E35" />
           <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="5.2.6.0" />
         </dependentAssembly>
       </assemblyBinding>
     </runtime>
     <system.webServer>
       <handlers>
         <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
         <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
         <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
         <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
         <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
         <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
       </handlers>
     </system.webServer>

     

     

  2. Todor
    Admin
    Todor avatar
    334 posts

    Posted 05 Sep 2018 Link to this post

    Hi Jennifer,

    We have replied to the support ticket you opened on the same issue.
    For the benefit of our community I will summarize the response also in this thread :

    From the code it looks that CORS has been enabled correctly.

    There is a long-existing issue in Chrome with localhost and CORS - check Access-Control-Allow-Origin: * doesn't match localhost bug.
    Is the issue indeed related to running the application in Chrome? If so, could you test the application in another browser and let us know if the issue remains?
    Deploying the application and testing it in Chrome from a non-localhost URI may also resolve the issue.

    Regards,
    Todor
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top