CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Aug 2012
    Posts
    6

    simulating an href link with WebRequest

    Hello
    I have a question about simulating the "<a hfer=..." Html tag behaviour in a C# application.

    i have a web page "A" which I can get normally using a browser . This page has a link ( actuallly an anchor , "<a href= ..." tag) to the page B, which is basically a page presenting a login form.

    I generally access "A" , then click on the link to "B" and everything works fine so that I can login.
    I even discovered, by looking into the "A" html code, that I can directly use the url written into the href attribute of the anchor to page "B":that is, if I put that url in the browser's adderss bar, I can directly access page "B" without first passing through "A", and login sucessfully.
    Now , what I want to do, is access the page "B" programmatically, through the use of href url, , using a WebRequest . I have been told that the href attribute in a html anchor uses a Http GET verb . So my thought is that , if I use a code like the following :

    WebRequest WRq = WebRequest.Create(UrlForPost2);
    WRq.Method = "GET";

    WebResponse WRe = WRq.GetResponse ();

    I should be able to download directly the page "B" .
    But this never happens . I always get a Http Error 500 (Internal Sserver Error).

    Some other guys advised me about the use of cookies , but I guess cookies are not the problem, since I can access directly the "B" page from a browser without accessing other pages before.

    Isn't the href attribute of an anchor a web request too ? which kind of request is that, and how can I simulate it into an application ?

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: simulating an href link with WebRequest

    Passwords are probably saved on the machine for your user
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured