Click here to Skip to main content
12,955,493 members (65,931 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi,

I deployed the service in windows server 2008 R2

i tried to update a record in db using the service. i have used 'put' method for update.

i called the service by ajax as follows -
<script type="text/javascript">
 
        function test() {
        ;
 
            var AssetUpdate = {
              
                logInInfo: { UserName: 'mark.ritter@e-isg.com', Password: 'password' },
                asset: {
                    AssetName: 'a',
                    Barcode: '1',
                    AssetDescription: '1',
                    AssetIDInternal: 'D2907B1D-8AE9-49D8-A905-65DD356858B2',
                    PeopleIDInternal: 'ED98D0E6-4AB4-41D4-9EC2-5A289D33595B',
                    LocationIDInternal: '48A986EA-00BE-46FC-A377-C19B63DA540C',
                    AssetCategoryIDInternal: '6E41C53F-BA24-4A8B-9892-79AF133549C7',
                    SiteIDInternal: '8A63BD8B-6B1A-4C91-96E5-3DE44FF07BC0',
                    AssetUsageID: '1',
                    AssetConditionID: '1',
                    AssetStatus: '12',
                    AssetSerialNo: '123',
                    Price: '12',
                    PurchaseDate: '01/01/2012',
                    PurchaseOrderNo: '55',
                    Quantity: '456',
                    Vendor: '67',
                    IsActive: 'True',
                    AuditDate: '01/01/2012',
                    AuditStatus: '4353',
                    Asset_UID: '1',
                    DataGatherID: '34',
                    ActualCost: '345',
                    FederalCost: '435',
                    MatchCost: '324',
                    Mfg: 'TEST',
                    Model: '1',
                    POLine: '1',
                    POStatus: '1',
                    ScannerDeviceCode: '1',
                    DateModified: '01/01/2012'
                }, AssetIDInternal: '5afb3768-db2f-42d1-8c47-3da008c6cdee'
            };
 
            try {
                $.ajax({
                     url: "http://172.16.0.110:80/vamsyncservices/api/Asset/UpdateAsset",
                  
                    type: "PUT",
                    dataType: 'json',
 
                   data: AssetUpdate,
 
                    success: function () {
                        alert("Done");
                        alert('Asset Updated successfully.');
                    },
                    Failure: function () {
                        alert("Fails");
                    }
 

                });
            }
            catch (e) {
                alert(e);
            }
        }     
 
    </script>

******************************************************************************
Config file :
<system.webServer>
   <modules>
      <remove name="WebDAVModule"/>
   </modules>

   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
       <add name="Access-Control-Allow-Headers" value="Content-Type" />
       <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
     </customHeaders>
   </httpProtocol>
   <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>


**********************************************************************************

When i run the script i got an error as follows
"XMLHttpRequest cannot load http://rest.e-isg.com/vamsyncservices/api/Asset/UpdateAsset. Origin http://localhost:52265 is not allowed by Access-Control-Allow-Origin."


Help ?
Posted 9-Nov-12 2:56am
Updated 9-Nov-12 3:52am
RaisKazi34.6K
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,719
CHill60 3,550
Maciej Los 3,153
ppolymorphe 2,060
Jochen Arndt 1,975


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 9 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100