codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  ?? Help with WebRequest maybe ??  dercha at 15:19 on Wednesday, May 17, 2006
 

Hello, I am fairly new to ASP.NET (C#)

I am looking for a way to call a web page and see what it returns.
For example call the page, http://www.page.com/login?accountname=me+password=you
if that page returns an error the function returns false if the page does not return an error the
function returns true.

I have been looking into using HTTPResponse and WebRequest but have not been successful at all.

Anyone have any thoughts on this?

Thanks,
~DE2

  Re: ?? Help with WebRequest maybe ??  dercha at 18:13 on Wednesday, May 17, 2006
 

OK This is how I got it working:

XmlDataDocument mydata = new XmlDataDocument();
protected bool isauthenticated(string username, string password)
{
bool do_it = false;

try
{
mydata.DataSet.ReadXml("http://page.com/logonUser?userName=" + username + "&password=" + password);
}
catch (Exception e)
{
if (e.Message.ToString() == "The remote server returned an error: (500) Internal Server Error.")
{
do_it = false;
}
else
{
do_it = true;
}
}

return do_it;
}

I know that if that error message is returned the the login faild. So I set do_it to false.

??This seems to work??

  Re: ?? Help with WebRequest maybe ??  JBelthoff at 01:34 on Sunday, May 21, 2006
 

The page that you are trying to access is not very secure if the poassword is passed in via the query string.

Anyway, you would not wan to use the xml unless the page you are trying to recieve is an xml document, or if it is a well formed XHTML document. Otherwise you would get an error in your read xml.

What you are looking to do is use the WebRequest method wich allows you to pass parameters with the request.

Of course if you are using only the querystring the webclient would suffice.

JB








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Nested Javascripts
•  ISP says linefeeds are causing problems
•  Linker Error Unresolved External Borland Builder 2006
•  Have multiple ASP.NET web projects share pages and controls
•  Re: How can I read ASCII data file in C++
•  Trouble writing programs
•  Validation Problem
•  Date formating from user input
•  Need help for writing javascript code global empty fields validation


Recent Articles
What is a pointer in C?
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net


© Copyright codetoad.com 2001-2006