2016년 3월 2일 수요일

wcf - Cross Domain XMLHTTP ERROR






Hi HanneSThEGreaT,
I saw your code and config file, it looked was right. But, in my opinion,
we should make sure your service is worked fine. We can use fiddler to debug it.
If it worked fine. That means the client issue, as far as I know, when we call a wcf service form moble
phone, we need to setHeader, like below:
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
Next, may be you can try add this section in your web.config file. Like this
 <standardEndpoints>
    <webScriptEndpoint>
      <standardEndpoint crossDomainScriptAccessEnabled="true"></standardEndpoint>
    </webScriptEndpoint>
  </standardEndpoints>
This node should be add as a child node of servicemodel.
For more information, please refer to the following articles:
Best Regards,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.ServiceModel.Activation;
using System.Web.Routing;
 
namespace StudentService
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.Add(new ServiceRoute("", 
                       new WebServiceHostFactory(), typeof(Service)));
        }
 
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
 
                HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                HttpContext.Current.Response.Cache.SetNoStore();
                
                EnableCrossDmainAjaxCall();
        }
 
        private void EnableCrossDmainAjaxCall()
        {
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin",
                          "http://localhost:5187");
 
            if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
            {
                HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", 
                              "GET, POST");
                HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers",
                              "Content-Type, Accept");
                HttpContext.Current.Response.AddHeader("Access-Control-Max-Age",
                              "1728000");
                HttpContext.Current.Response.End();
            }
        }
    }
}


참고사이트
https://social.msdn.microsoft.com/Forums/vstudio/en-US/87561b52-24d2-42a1-a9c8-e52fecaab275/enabling-cors-on-a-wcf-service?forum=wcf



댓글 1개:

익명 :

How to get the HP Envy 5055 Driver from the HP website?
1.To begin with, navigate to the hp support page
2.Find the software and drivers option on the top blue bar
3.In the next page select the option as printer
4.You will have to type in the printer model which is, in this case, HP Envy 5055
5.The next page will have the list of HP Envy 5055 drivers
6.Choose the correct one and click on the download
7.After the download completes, continue with the instructions on the screen to complete the HP Envy 5055 driver
If you want to know anything else regarding the HP printers, call us using the toll-free number.