1

I recently used web.DownloadString() function in my ASP.Net MVC application and I'm wondering that Is there any equivalent java script function for ASP.Net method web.DownloadString ????

3
  • as far as i know, there is nothing..
    – Pranav
    Commented Jun 19, 2013 at 12:00
  • 1
    I don't know if there's an option for it, also you have to keep in mind that web.downloadstring works cross domain, which javascript won't let you do. Depending on what you're trying to accomplish you can create a webmethod in your .net application and access that with javascript, and in the webmethod call downloadstring. It's a little more overhead, but not much.
    – Smeegs
    Commented Jun 19, 2013 at 12:01
  • If the string you're trying to download is in the same domain as the page you're executing your javascript, you can do it with an ajax call either using the XMLHttpRequest object, or maybe jQuery's various ajax functions.
    – Dan
    Commented Jun 19, 2013 at 12:10

1 Answer 1

0

There's no such equivalent in javascript because of the Same Origin Policy restriction built in browsers which prevents you from retrieving resources on other domains. But assuming you could overcome this restriction (with techniques like CORS) you could use AJAX. Alternatively you could setup a controller action on your domain which will act as a bridge -> this action will retrieve resources from remote domains using a WebClient and then you could use javascript to send an AJAX request to this controller action.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.