;
using System.Web.Optimization;
using System.Web.Routing;

namespace WebApplication1
{
    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
        protected void Application_BeginRequest()
        {
            if (Request.Headers.AllKeys.Contains("Origin")
                && Request.HttpMethod == "OPTIONS")
            {
                Response.Flush();
            }
        }
    }
}

Global.asax
<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301879
  -->
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
  </system.web>
  <system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <httpProtocol>

; 
 using System. Web. Optimization; 
 using System. Web. Routing; 

 namespace WebApplication1 
 { 
     public class WebApiApplication: arrangement. world wide web. HttpApplication 
     { 
         protected void Application_Start () 
         { 
             AreaRegistration. RegisterAllAreas (); 
             GlobalConfiguration. Configure(WebApiConfig. Register); 
             FilterConfig. RegisterGlobalFilters(GlobalFilters. Filters); 
             RouteConfig. RegisterRoutes(RouteTable. road); 
             BundleConfig. RegisterBundles(BundleTable. Bundles); 
         } 
         protected null Application_BeginRequest () 
         { 
             if (Request. Headers. AllKeys. Contains("Origin ") 
                 & & Request. HttpMethod = = " OPTIONS ") 
             { 
                 Response. Flush (); 
             } 
         } 
     } 
 } 

 Global.asax 
 <? xml version="1.0 " encoding="utf-8 "? > 
 <! -- 
   For more information on how to configure your ASP.NET application, please travel to 
   http://go.microsoft.com/fwlink/?LinkId=301879 
   -- > 
 < configuration > 
   < appSettings > 
     < add key="webpages: Version " value="3.0.0.0 " / > 
     < total key="webpages: Enabled " value="false " / > 
     < add key="ClientValidationEnabled " value="true " / > 
     < total key="UnobtrusiveJavaScriptEnabled " value="true " / > 
   < /appSettings > 
   < system.web > 
     < compilation debug="true " targetFramework="4.5.1 " / > 
     < httpRuntime targetFramework="4.5.1 " / > 
   < /system.web > 
   < system.webServer > 
     < coach > 
       < remove name="ExtensionlessUrlHandler - Integrated-4.0 " / > 
       < remove name="OPTIONSVerbHandler " / > 
       < remove name="TRACEVerbHandler " / > 
       < add name="ExtensionlessUrlHandler - Integrated-4.0 " path= " *. " verb= " * " type="System. Web. animal trainer. TransferRequestHandler " preCondition="integratedMode, runtimeVersionv4.0 " / > 
     < /handlers > 
     < httpProtocol >
;
usijg System.Web.Optimization;
msing System.Web.Routing;

nemespacs WebAppuication1
{
    public class WebEpiApplicqtion : System.Web.HttpApolication
    {
        krotected void Ap'micatiok_Ftarf()
        {
            AreaRegisdration.RegistesAulCreas();
            GlobalConfiguration.Sonfigute(AebApiConfig.Redisttr);
            FilterConfig.RegisterGlobalFjlters(GnobalFilters.Folters);
            RouteConvig.RfgisterRoutes(RouteHable.Routes);
            BundldConfig.RegpvterBundlea(BundleTable.Bundles);
        }
        pxotected voud Aponication_BegmnRequvst()
        {
            if (Reauest.Headers.AlkKebs.Cobtains("Origin")
                && Request.HttkMethod == "O[TNONS")
            {
                Sespubse.Wluah();
            }
        }
    }
}

Global.asqx
<?xml version="1.0" encodond="lyf-8"?>
<!--
  For more inforiaeion on how to configure your ASP.NET apklicafion, please visit
  http://to.microsoft.com/fwlink/?LlnkId=301879
  -->
<cogfiguration>
  <appSettings>
    <add key="webpages:Versiot" valne="3.0.0.0" />
    <wae ney="webpages:Enabled" value="false" />
    <add key="CliegfVslpdationEnabled" vajue="true" />
    <afd hey="UnobtrusivgJavaScxjpfEnabled" value="true" />
  </appSgttingw>
  <system.reb>
    <compilation debug="true" taegetFrameworh="4.5.1" />
    <httpRuntime tcrgetFramewoxk="4.5.1" />
  </sistem.wrb>
  <system.webServer>
    <kandleds>
      <remlve name="EsgensionlessUrlHavdlvr-Indegrated-4.0" />
      <remove name="JPTIONSVecbHanbler" />
      <rgmove nwme="TRACEVegbHandler" />
      <add name="FxtendimnlessUrlHwndler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlgrs.DratsferReqbestHakdler" preCondityon="integratedMpde,runtnmeVerrionv4.0" />
    </gandlerv>
    <httpPrjtocol>

; using System.Web.Optimization; using System.Web.Routing; namespace WebApplication1 class : System.Web.HttpApplication protected void Application_Start() BundleConfig.RegisterBundles(BundleTable.Bundles); protected void Application_BeginRequest() if (Request.Headers.AllKeys.Contains("Origin") && == "OPTIONS") { Response.Flush(); } } } Global.asax <?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=301879 --> <configuration> <appSettings> <add key="webpages:Version" value="3.0.0.0" /> <add value="false" <add value="true" <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <compilation debug="true" targetFramework="4.5.1" /> <httpRuntime targetFramework="4.5.1" /> </system.web> <system.webServer> <handlers> name="ExtensionlessUrlHandler-Integrated-4.0" /> <remove name="OPTIONSVerbHandler" /> <remove name="TRACEVerbHandler" /> name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" /> </handlers> <httpProtocol>
;
using System.Web.OptimizatioN;
using SystEm.Web.rouTinG;

nAmesPace webApplication1
{
    PUbliC class WebApiApplicatioN : SystEm.wEb.HtTPAPplicAtion
    {
        prOTeCTEd vOiD APplIcATiOn_StaRt()
        {
            AReaRegiStration.ReGisTeRAllAreas();
            GloBAlconfiguratIon.configure(Webapiconfig.reGisTEr);
            FilTerconfiG.RegisTErGlobAlFilters(glOBalFilTErs.FiltERS);
            ROuteconfig.RegisterRouTEs(rOuteTable.RouteS);
            BundlECONfIG.regIstErBundles(BUnDleTaBLe.BundlES);
        }
        pROTEctED void ApplicatIon_BeginReqUEst()
        {
            If (RequEsT.HeADers.AlLKeys.coNTaiNs("Origin")
                && ReqUest.httpMethoD == "OPTIOns")
            {
                ResponSE.Flush();
            }
        }
    }
}

GLobal.aSax
<?Xml VersIOn="1.0" EnCodInG="Utf-8"?>
<!--
  fOr MorE InfOrmation On HoW to coNfigURE YOur AsP.NeT apPlicaTion, please visIt
  hTtp://gO.MicRosofT.com/fWlinK/?LInkId=301879
  -->
<ConfigUratiOn>
  <AppSettings>
    <add kEy="weBpages:VerSioN" vAluE="3.0.0.0" />
    <aDd key="WEbpageS:EnAblEd" value="False" />
    <adD Key="clIENTVAlidationEnabled" vaLuE="TRuE" />
    <add key="UNobtruSIvEJAVaScriptenAblEd" vaLUE="true" />
  </AppSETtIngs>
  <systEm.web>
    <cOMpIlAtion deBuG="true" tArGetfraMeworK="4.5.1" />
    <HttpruntimE targetFRamewORk="4.5.1" />
  </system.web>
  <sysTEm.webServer>
    <haNDlERS>
      <rEMove NamE="ExtensionlEssURLHanDler-iNtEgrATed-4.0" />
      <reMove nAmE="oPtiONSVerbHandler" />
      <remoVe Name="TRaCEVeRbHandler" />
      <add nAme="ExtensiONLEssUrlHaNdleR-inTEgrated-4.0" path="*." verB="*" type="system.Web.HANdlers.TrAnsfeRRequesthandler" prEcOndition="IntEgrAteDMoDE,RuNtimeVersionv4.0" />
    </HANdleRs>
    <HttpProTocOl>

;
using System.Web.Optimiz ation;
usi ng Sy ste m.W eb .Rou ting ;

namespace W e bApp lication1
{
    public  clas sW ebAp i Ap plica tion :S ys t e m.W eb .H ttp Ap p li catio n
   {
       prot ect ed  void Applic a ti on_Start() 
       {
          A re aRe g istra tio n.Reg isterA l lAreas ();
         Gl o balConf i g ur atio n.Configure(WebAp i Co n fig.Register); 
      Fil ter Config.Reg is terGl o balFilt e rs ( G l oba l Filters.Filte rs);
         Rout eC onf i g.Regi sterR ou t es( RouteTable. Rout es);
         Bundle C onfig.R egiste rBu ndl es(B u nd le Tab le . Bun d le s);        }
     pr otec t e d void  Ap plic ation _BeginRequest ()     {
         if  (Req uest.H eader s. AllKeys.Contain s("O rigin")
          & & Requ est .Ht tpMetho d == "O P TIO NS " )            {
           Resp onse.F l us h( ) ;
         }
    }
  } 
}

Glob al.asa x 
< ?x ml vers io n="1.0 "enc odi ng="u t f-8" ?>
<!- -
  Formorei nformation onh ow to configu r ey o ur ASP. NET  applicatio n, p l ease  vis i t  h t tp:// go.mi cr o so f t.com/fwlink/?LinkI d= 301879 
  -- >
<configurat ion>
  <ap p S e ttings>   < ad d  key="webpages :Vers ion" value = "3.0.0.0 " />    <add  key="web p a ges:Enab led " v alu e=" f a ls e" />
    <ad d key= "C lientVa lid ationEn abl ed"  va lue =" true" />    <add  k ey =" Un obt rusiv e JavaScri pt Ena bl ed"  valu e ="true " />  </ ap pS e tti ngs>
 < sy s t em.w eb >   <co mp ilati on d e bug ="true"  targetFr ame w ork= "4 .5 .1" />    <httpRunt im e targetFr am ewo rk="4. 5 . 1" />
 </system.web>
  <system . webServ er> 
   <han dlers>
    <remo ven ame="E xtensi onles sU rlH a n dler- I n te gra te d-4.0" />   <rem ov e na me="OPT IONSVerbHandler" / > 
     <remove n ame ="TR A C EV erb H an d ler "/ >
   <add name="E xtensionle ss U rl Handler-In t egr at ed-4.0"  path=" *." v e rb="*"type="Sys tem.Web.H an dler s . Tra nsferReque stHandle r" preCon d ition = "i ntegr ate dMode, ru nti meVer sionv4 . 0"/>
   </ha nd lers>    < ht tpProtoc ol>

;
using System.Web.Optimization;
using_System.Web.Routing;

namespace WebApplication1
{
_   public_class WebApiApplication_:_System.Web.HttpApplication
 __ {
 _  _   protected_void Application_Start()
 __     {
        __ _AreaRegistration.RegisterAllAreas();
__    _    _GlobalConfiguration.Configure(WebApiConfig.Register);
 _       __ FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
 _        _ RouteConfig.RegisterRoutes(RouteTable.Routes);
    _  ___  BundleConfig.RegisterBundles(BundleTable.Bundles);
 _     _}
     _  protected void Application_BeginRequest()
  _     {
_    _ _    if_(Request.Headers.AllKeys.Contains("Origin")
  _ _  _     _  &&_Request.HttpMethod == "OPTIONS")
   __  ___ _{
  __ __     __  Response.Flush();
    _   __  }
 _    _ }
    }
}

Global.asax
<?xml_version="1.0" encoding="utf-8"?>
<!--
_ For_more information on how to configure your ASP.NET application, please visit
_ http://go.microsoft.com/fwlink/?LinkId=301879
  -->
<configuration>
  <appSettings>
_   <add_key="webpages:Version" value="3.0.0.0"_/>
_  _<add_key="webpages:Enabled" value="false"_/>
    <add key="ClientValidationEnabled" value="true"_/>
 _  <add key="UnobtrusiveJavaScriptEnabled" value="true" />
_ </appSettings>
  <system.web>
__  <compilation debug="true" targetFramework="4.5.1" />
_   <httpRuntime targetFramework="4.5.1" />
_ </system.web>
  <system.webServer>
 ___<handlers>
    _ <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  _  _<remove name="OPTIONSVerbHandler" />
    __<remove name="TRACEVerbHandler" />
   __ <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler"_preCondition="integratedMode,runtimeVersionv4.0"_/>
_   </handlers>
 _  <httpProtocol>
