none
WCF does not allow to call its function from other domain ? RRS feed

  • Question

  • i know web api does not allow call from other domain but if i want that my web api accept request from other domain then i have to enable cors in web api in code.

    so i like to know wcf behave same way ? i am not sure about this.

    if other domain will call my wcf function by jquery or httpclient then do i need to set any setting for cors in wcf ?

    please guide me.

    thanks

    Friday, December 2, 2016 2:36 PM

Answers

All replies

  • Friday, December 2, 2016 9:04 PM
  • i just like to know can we call wcf service from other domain because for web api we need to enable cors to make possible call from other domain. so please tell me what happen in wcf or asmx ?

    thanks

    Friday, December 2, 2016 9:23 PM
  • i just like to know can we call wcf service from other domain because for web api we need to enable cors to make possible call from other domain. so please tell me what happen in wcf or asmx ?

    thanks


    Why don't you do some prototyping, and you  tell us. 
    Saturday, December 3, 2016 12:58 AM
  • Hi Mou_inn,

    >> if other domain will call my wcf function by jquery or httpclient then do i need to set any setting for cors in wcf ?

    You need to enable CORS in WCF.

    CORS is restrict of web browser for security reasons. A web application could only make HTTP request to its own domain. To allow cross-domain requests, we need to add AccessControlAllowOrigin and some other related headers to the requests.

    To implement CORS in WCF, I suggest you refer the links below for how WCF adds related headers to the requests:

    # Implementing CORS support in WCF

    https://blogs.msdn.microsoft.com/carlosfigueira/2012/05/14/implementing-cors-support-in-wcf/

    # WCF: CORS support for self-hosted WCF REST service

    https://blogs.msdn.microsoft.com/dsnotes/2016/08/31/wcf-cors-support-for-self-hosted-wcf-rest-service/

    Best Regards,

    Edward

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Sudip_inn Monday, December 5, 2016 9:18 AM
    Monday, December 5, 2016 3:07 AM
  • from other domain when we create web reference of web service then we do not have to enable any cors feature.........why ?

    say a service has been developed by wcf template by a company1 and company2 create the web reference means proxy in their asp.net project and calling service function and getting response. tell me in this kind of situations service does not need to enable cors then when we call service from company2 web site by jquery then cors has to enable why ?

    if we call web service by httpclient then also cors need to be enable ?

    please explain the reason in details. thanks

    Monday, December 5, 2016 9:22 AM
  • Hi Mou_inn,

    >> from other domain when we create web reference of web service then we do not have to enable any cors feature.........why ?

    CORS defines a way in which a browser and server can interact to determine whether or not it is safe to allow the cross-origin request. Certain "cross-domain" requests, notably AJAX requests, however are forbidden by default by the same-origin security policy.

    Please pay attention to that it is between a browser and server. So, SOAP would not fire CORS.

    >> if we call web service by httpclient then also cors need to be enable ?

    As my above statement, CORS is between browser and server, httpclient would not hit CORS.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 7, 2016 2:50 AM