can we post/put/delete using jsonp in asp.net webapi?http://forums.asp.net/t/1800703.aspx/1?can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Fri, 11 May 2012 16:04:03 -040018007034967863http://forums.asp.net/p/1800703/4967863.aspx/1?can+we+post+put+delete+using+jsonp+in+asp+net+webapi+can we post/put/delete using jsonp in asp.net webapi? <p>Using asp.net webApi<br> <br> I've site1 (http://localhost:53723) and site2 (http://localhost:64009).<br> I want to fetch data from site2 to site1 (Cross domain, not same origin).<br> <br> We can use jsonp for this, and I've achieved data.<br> <br> Can we use jsonp to post/put/delete verb for cross domain (not same origin)?</p> 2012-05-06T19:18:27-04:004967865http://forums.asp.net/p/1800703/4967865.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>JSONP was a hack to get around the same-origin issue and it's used to get data. Under the covers it's using a &lt;script&gt; tag to make the HTTP request, so it's only using GET and thus those types of HTTP requests should not perform database updates, inserts or deletes.</p> <p></p> 2012-05-06T19:21:02-04:004967877http://forums.asp.net/p/1800703/4967877.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>Thanks BrockAllen,</p> <p>That means we can only fetch using jsonp in cross-domain.</p> <p>Then my next question is related to asp.net webapi:<br> I want to make one source for all information (webapi) and use multiple platform to use it (website, mobile app, desktop app, etc)</p> <p>This'll be cross-domain because i'll keep my webapi as one site and others platform in different site/app store/pc/mac.<br> So fetching from cross-domain is no issue, but what if i need post/put/delete action?</p> <p>The answer for this might be use proxy (HttpClient in this case)?<br> If i'm using proxy then why to invent webapi, we can do the same with WCF Restful service.</p> <p>Just trying to understand why asp.net webapi?</p> 2012-05-06T19:56:25-04:004968039http://forums.asp.net/p/1800703/4968039.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p><a href="http://blogs.msdn.com/b/carlosfigueira/archive/2012/02/20/implementing-cors-support-in-asp-net-web-apis.aspx">Cors </a>is another the option.</p> 2012-05-07T01:48:11-04:004969408http://forums.asp.net/p/1800703/4969408.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>CORS isn't really an option for people who want to support IE.</p> <p>IE has its own implementation, but it does NOT support delete/put. It only is GET/POST.</p> <p>What I've done (which sucks) is create the GET/POST/DELETE/PUSH verbs like normal, then have another service that posts to the same URLs but prefix the url with get/post/delete/push and build up the request and forward it to the real verb.</p> <p>ie: &nbsp;POST www.example.com/post/fruit/apple?name=something&amp;whatever=foo&amp;also=bar</p> 2012-05-07T15:25:46-04:004969858http://forums.asp.net/p/1800703/4969858.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>X-HTTP-Method-Override is another option.</p> <p><pre class="prettyprint">http://www.matlus.com/delegatinghandler-for-x-http-method-override/</pre></p> 2012-05-08T01:50:58-04:004969895http://forums.asp.net/p/1800703/4969895.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>What exactly are you talking about in reference too? You can't do headers in JSONP.</p> 2012-05-08T02:44:54-04:004969908http://forums.asp.net/p/1800703/4969908.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>digitalpacman</h4> What exactly are you talking about in reference too? </blockquote> <p></p> <p>I am talking about CORs man.</p> <p></p> 2012-05-08T03:15:08-04:004969909http://forums.asp.net/p/1800703/4969909.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>Ahhh! Good stuff. I might actually implement that where I work as well. This is for the IE problems with &quot;CORS&quot;, yes?</p> 2012-05-08T03:16:47-04:004976816http://forums.asp.net/p/1800703/4976816.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>Thanks Imran,</p> <p></p> <p>Was looking @ the article you provided (http://blogs.msdn.com/b/carlosfigueira/archive/2012/02/20/implementing-cors-support-in-asp-net-web-apis.aspx), have following question.</p> <p>We allow to response back with any request with 'origin' in header. Then how safety in place? Anyone call this and make attempt of CSRF.<br> Do we need to filter 'origin' in server side?</p> <p>Please advice!</p> 2012-05-11T15:22:00-04:004976832http://forums.asp.net/p/1800703/4976832.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>To stop people from sending users directly to your API to do actions, you can do HMAC.</p> <p>HMAC will encrypt the transport with a private key, pass a public key, and the server will know what the users private key is and do the same encryption (normally you find the private key using the public key) and check to verify the response is the same.<br> Then ontop of that, you can accept SSL only and send the datetime (suggested) in the header, and deny all responses that are 5 seconds old. This will stop people from copying requests and sending them multiple times (via packet sniffing).&nbsp;</p> 2012-05-11T15:33:18-04:004976883http://forums.asp.net/p/1800703/4976883.aspx/1?Re+can+we+post+put+delete+using+jsonp+in+asp+net+webapi+Re: can we post/put/delete using jsonp in asp.net webapi? <p>Make sense, means needs to take care on server side.<br> Thanks a lot @digi &amp; @imran.</p> <p><strong>At the conclusion:</strong><br> Only for Get verb: We can use JSONP<br> for all verbs (Get, Post, Put, Delete): We can use CORS<br> One should be concerned about security also who can call your webapi service.</p> <p></p> 2012-05-11T16:04:03-04:00