asp.NET login using HTTP post method with jsoup

Arnold Asllani

I am recently trying to develop a android app for my school friends so they do not have to use a web browser but an simple app to check their updated grades and exam schedule but since the school wont give permission to use their DB the only method is to do HTML parsing. so I found this library Jsoup and an example and started writing my own code but it always brings me the page source of login in page (It doesnt log in at all)

public Document getHTMLsoure() {
Document doc=null;
    try {
         doc = Jsoup.connect("http://karinca.meliksah.edu.tr")
                 .data("ctl00$ContentPlaceHolder1$txtKullaniciAdi","usernm")
                .data("ctl00$ContentPlaceHolder1$txtSifre", "passwd")
                .data("ctl00$ContentPlaceHolder1$btnLogin", "Giriş")


                .userAgent("Mozilla")

                .post();
    } catch (IOException e1) {
        e1.printStackTrace();
    }

return doc; }

Hasanaga

Please check it.
Result Kullanıcı adı yada şifre hatası !

Response res = Jsoup
        .connect("https://karinca.meliksah.edu.tr/View/Login")
        .userAgent("Mozilla")
        .execute();

Document doc = res.parse();

String eventArgument = doc.select("input[name=__EVENTARGUMENT]").val();
String viewState = doc.select("input[name=__VIEWSTATE]").val();
String viewStateGenerator = doc.select("input[name=__VIEWSTATEGENERATOR]").val();
String eventValidation = doc.select("input[name=__EVENTVALIDATION]").val();
String asyncPost = "true";

String ct = "";

String body = doc.body().html();

int indexOf = body.indexOf("Sys.WebForms.PageRequestManager._initialize(");;
if(indexOf > -1){

    int indexEnd = body.substring(indexOf).indexOf("');");

    if(indexEnd > -1){

        String temp  = body.substring(indexOf, indexOf+indexEnd);
        int indexStart = temp.lastIndexOf("'");
        ct = temp.substring(indexStart+1,temp.length());
    }
}

Document   doc1 = Jsoup.connect("https://karinca.meliksah.edu.tr/View/Login.aspx")

    .referrer("https://karinca.meliksah.edu.tr/View/Login")
    .cookies(res.cookies())
    .data(ct+"$ContentPlaceHolder1$ScriptManager2",ct+"$ContentPlaceHolder1$UpdatePanel1|"+ct+"$ContentPlaceHolder1$btnLogin")
    .data(ct+"$ContentPlaceHolder1$txtKullaniciAdi","usernm")
    .data(ct+"$ContentPlaceHolder1$txtSifre", "passwd")
    .data("__EVENTTARGET",ct+"$ContentPlaceHolder1$btnLogin")
    .data("__EVENTARGUMENT",eventArgument)
    .data("__VIEWSTATE",viewState)
    .data("__VIEWSTATEGENERATOR",viewStateGenerator)
    .data("__EVENTVALIDATION",eventValidation)
    .data("__ASYNCPOST",asyncPost)
    .userAgent("Mozilla")
    .post();


System.out.println(doc1.html());

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Login to website through Jsoup post method not working

How to post form login using jsoup?

ASP.NET Core MVC : HTTP POST method not return to view

Login method in asp.net

How can I put variables from http get method to http post method in asp.net

Why does an http get method accepts http post request in asp.net web api?

HTTP Error 405.0 - Method not allowed error in asp.net mvc 4 post method

Login on website using jsoup

Login using Jsoup

Login to webpge using Jsoup

ASP.NET Web API Login method

AngularJS $http.post() sends null to ASP.NET web API controller method

HTTP CODE 405 (Method Not Allowed), When I sent POST data in ASP.NET WebAPI CORS

ASP.NET Core HTTP Error 405 - Bad Method when routing to post controller action

From ReactJS to ASP.NET Core 6.0 HTTP POST method cannot receive data

How to serve POST request to http://domain_name.com using ASP.NET using a controller

Angular $http post with ASP.NET MVC

Web service asp.net POST method

Execute second POST method JSoup

Login using cookies is not working in ASP.net

Send HTTP POST message in ASP.NET Core using HttpClient PostAsJsonAsync

How can i post both file and text data to web api using asp net core http client?

POST method calling from service Angular 6 to the REST using web api in asp.net mvc

How to document a POST (HTTP method) using ControllerLinkBuilder?

using jetty to test a method that performs http post

ASP.NET Web API: Perform Search on Table using HTTP GET Method and Linq to SQL Dynamically

Using factory method to create typed HTTP client, ASP.NET Core 2.1

Login Example in Android using POST method using REST API

POST request to HTTPS using Net::HTTP