1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problem with XMLHTTP in ASP 3.0

Discussion in 'C#' started by suraj_ajax, Mar 3, 2009.

  1. #1
    Hi

    i have been trying to get the contents from a webpage using MSXML2.ServerXMLHTTP . Although i had done the same in past without any issues..

    but now while get a content from a page , i am getting no response.text . Have checked the status it says 200. Seems like the problem is due to character encoding . Below the is the page in question

    http://indiacode.nic.in/qrydisp.asp?tfnm=188712 &tfnm2=1

    Code i am using is

    <%
    strUrl="http://indiacode.nic.in/qrydisp.asp?tfnm=188712%20&tfnm2=1"
    Set xmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP")
    xmlHttp.Open "GET", strUrl, False
    xmlHttp.setRequestHeader "User-Agent", "asp httprequest"
    xmlhttp.setRequestHeader "Content-type", "text/xml; charset=utf-16"
    xmlHttp.Send
    getHTML = xmlHttp.responseText
    xmlHttp.abort()
    set xmlHttp = Nothing
    response.write getHTML
    %>

    Can u please guide me how to get the contents..
     
    suraj_ajax, Mar 3, 2009 IP
    wacamoi likes this.
  2. wacamoi

    wacamoi Peon

    Messages:
    810
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    try this

    <%
    url = "http://*****"
    set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
    xmlhttp.open "GET", url, false
    xmlhttp.send ""
    Response.write xmlhttp.responseText
    set xmlhttp = nothing
    %>
    ps: not sure MSXML2 works for all hosts
     
    wacamoi, Mar 3, 2009 IP
  3. suraj_ajax

    suraj_ajax Peon

    Messages:
    26
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi

    Seems like the code which you had given is quite similar to what i had used except the requestheader thing..

    Anyways .. i had tried it again.. but the same problem .. i am getting no result. the output is blank
     
    suraj_ajax, Mar 3, 2009 IP
  4. wacamoi

    wacamoi Peon

    Messages:
    810
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I just tried the code and it was function well.

    As I noted. Maybe your host does not support MSXML V2.X or too many errors appeared and need to be clean at host server.

    Ask your host support. To make sure.
     
    wacamoi, Mar 4, 2009 IP
  5. suraj_ajax

    suraj_ajax Peon

    Messages:
    26
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    For time being . .i am trying this code on my local comp ..

    I am able to get data from other pages.. but this particular pages is giving me fever ..

    Have even tried using the following .. but still no success

    "xmlhttp.setRequestHeader "Content-type", "text/HTML; charset=utf-8" "
     
    suraj_ajax, Mar 4, 2009 IP
  6. wacamoi

    wacamoi Peon

    Messages:
    810
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you are focusing on the URL you provided.
    I do checked but only can get "indiacode.nic.in" home page info and can not get info from "indiacode.nic.in/****"
    It may because the site block all XMLHTTP from the 3rd paty.

    Take a look Google search by [ site:indiacode.nic.in ] the site may also block G bots.
    I think it is not the code problem.
     
    wacamoi, Mar 5, 2009 IP
  7. suraj_ajax

    suraj_ajax Peon

    Messages:
    26
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    suraj_ajax, Mar 5, 2009 IP
  8. suraj_ajax

    suraj_ajax Peon

    Messages:
    26
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi

    I finally got the solution.. here is the tweak..

    just replaced
     getHTML = xmlHttp.responseText 
    Code (markup):
    with

    getHTML = xmlHttp.ResponseBody
    Code (markup):

    Thanks for replying wacamoi

    Regards
    Suraj jain
     
    suraj_ajax, Mar 25, 2009 IP
  9. wacamoi

    wacamoi Peon

    Messages:
    810
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Good to hear that Suraj jain

    it is also nice that you are willing to share the solution

    not many people will do like you

    Thank you too.
    Best Reagrds,

    Wacamoi
     
    wacamoi, Mar 25, 2009 IP
  10. palme

    palme Active Member

    Messages:
    320
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #10
    i guess ResponseBody takes only the body part of the webpage , not whole page.
     
    palme, Apr 2, 2009 IP