Base solution for your next web application
Open Closed

Error CORS - Only on delete #4759


User avatar
0
gbadenhorst created

Hi,

I've deployed an initial version of a website and the problem i am experiencing now is a rather annoying one. How does CORS interact with the overall functions(Post/Put/Delete/etc) of ASP Net Zero?

I have no problems updateding, creating or viewing data but when I try to delete it blocks me with: products:1 Failed to load <a class="postlink" href="http://api">http://api</a>.{domain}.co.za/api/services/app/Products/Delete?Id=641: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://{domain}.co.za' is therefore not allowed access. The response had HTTP status code 405.

As far as I know I followed all the steps correctly when deploying including the config files with all the forward slashes etc.

I am using the latest version of Angular + Core.

Here is extracts from my config files: Code Config: "ServerRootAddress": "http://api.{domain}.co.za/", "ClientRootAddress": "http://{domain}.co.za/", "CorsOrigins": "http://{domain}.co.za,http://localhost:49152" Angular Config: "remoteServiceBaseUrl": "http://api.{domain}.co.za", "appBaseUrl": "http://{domain}.co.za",

Is there something I'm doing wrong here?

Any assistance would be greatly appreciated.


8 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @GBadenhorst probably the problem is not related toCORS. Can you check your api website's logs ? It must be placed as "App_Data/Logs.txt".

  • User Avatar
    0
    gbadenhorst created

    @ismcagdas This is a live/deployed environment, not during debugging. From what I understand and could find, this "App_Data/Logs.txt" is only in debug mode.

    Am I missing something, like another log location for live/deployed?

  • User Avatar
    0
    alirizaadiyahsi created

    You should see logs at same place in live environment. Of course you should allow write access to your deployment folder.

  • User Avatar
    0
    gbadenhorst created

    HI,

    I have the logs on (stdout=true). I also have full access assigned to the deployment folders. However, I have not managed to get them working as of yet. They always give the error that they can't be created, no matter where I deploy them.

    Warning: Could not create stdoutLogFile \?\C:\inetpub\BMS_API\logs\stdout_5720_20183832812.log, ErrorCode = -2147024891.

    I have seen several posts regarding fixes for this but most of them relate to editing the csproj file as a "workaround". I would rather have the correct way to resolve such a scenario than a quick fix which has been around since Core 1.0.

    Is there something else I am missing, I assume someone has had this with the ASP.Net Zero project at some point?

    The thing that I don't understand about this whole scenario of CORS. 70% of my functionality is default methods generated with all the basics of the ASP Net Power tools and they work. But Delete and system related updates don't work. I tried updating the Visual settings now and I get CORS error when I save.

  • User Avatar
    0
    gbadenhorst created

    Funny enough, it is not that CORS is the problem. The main culprit, in this case, is WebDAV.

    You need to configure the webconfig file to remove webdav module and webdav in order to fix things like posts being handled as puts and stuff like that. The below fixes the issue it seems. As I can't remove WebDAV from IIS, the only way is to remove it this way.

    <system.webServer> <ins><modules runAllManagedModulesForAllRequests="true"> <remove name="WebDAVModule" /> </modules></ins> <handlers> <ins><remove name="WebDAV" /></ins> <add name="aspNetCore" path="" verb="" modules="AspNetCoreModule" resourceType="Unspecified" /> </handlers>

  • User Avatar
    0
    ismcagdas created
    Support Team

    @GBadenhorst you should be able to uninstall WebDav if you want to. Details are here <a class="postlink" href="https://docs.microsoft.com/en-us/iis/install/installing-publishing-technologies/installing-and-configuring-webdav-on-iis">https://docs.microsoft.com/en-us/iis/in ... dav-on-iis</a>.

  • User Avatar
    0
    gbadenhorst created

    Hi,

    In normal circumstances, I would be able to but on this specific server, I am unable to remove(untick) it in Roles & Features.

    I'll stick with this method in case the client needs to use WebDAV at some stage for something else.

    Thank you.

    Regards, Gideon Badenhorst

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks for the feedback @GBadenhorst.