none
WebClient und Credentials RRS feed

  • Allgemeine Diskussion

  • Hallo,

    ich habe ein Problem beim Aufruf einer Url, welche eine Authentifizierung erfordert. Dieser Service soll einen Fehler zurücksetzen. 

    Ich rufe folgendes auf:

    string user = ConfigurationManager.AppSettings["user"].ToString().Trim();
    string pw = ConfigurationManager.AppSettings["pw"].ToString().Trim();
    string url = string.Empty;
    url = ConfigurationManager.AppSettings["reseturl"].ToString().Trim();
    string port = ConfigurationManager.AppSettings["port"].ToString().Trim();
    string tid = ConfigurationManager.AppSettings["terminal"].ToString().Trim();
    string req = ConfigurationManager.AppSettings["req"].ToString().Trim();
    
    url += "&port=" + port + "&tid=" + tid + "&req=" + req;
    
    WriteStatistic(url);
    
    WebClient client = new WebClient();
    if (!string.IsNullOrEmpty(user) && !string.IsNullOrEmpty(pw))
    {
    	client.Credentials = new NetworkCredential(user, pw);
    }
    string content = client.DownloadString(url);
    
    WriteStatistic("Alarm resetted: " + content);

    Ich erhalte dann dieses :

    <html>
    <head>
    <title>ARCB webservice v2.2.2</title>
    <link rel="stylesheet" href="kl1.css" type="text/css">
    <link rel="Shortcut Icon" type="image/x-icon" href="d_d.png" />
    </head>
    
    <body>
    
    <blockquote>
    <h2>Login</h2>
    <table width="700" cellpadding="5"><tr><td bgcolor="#e0e0ff">
    
    <form action="auth.klx" method=post>
        Username: <input type=text name=usr><p>
        Password: <input type=password name=pwd><p>
        <input type=submit name=login>
    </form>
    </td></tr></table>
    <font size="-1">
    <a href=index.klx>Back to the main page</a>
    </font>
    </blockquote>
    </body>
    </html>

    Das heißt, dass die Login Seite zurückgegeben wird.

    Was kann ich noch probieren, dass ich das hin bekomme?

    Gruß

    Mario

    • Typ geändert Ciprian Bogdan Freitag, 21. März 2014 16:01 keine Rückmeldung des Fragestellenden
    Samstag, 8. März 2014 21:44

Alle Antworten