powered by simpleCommunicator - 2.0.59     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / socket operation was attempted to an unreachable network
2 сообщений из 2, страница 1 из 1
socket operation was attempted to an unreachable network
    #38625489
NetCoder
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте. Я пытаюсь заолгиниться через Фейсбук. Ниже мой код:

Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
readonly static string App_ID = "someID";
readonly static string App_Secret = "someCode";
readonly static string scope = "email";
readonly static DataContractJsonSerializer userSerializer
    = new DataContractJsonSerializer(typeof(FacebookUser));

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        string code = Request.QueryString["code"];
        string error_description = Request.QueryString["error_description"];
        string originalReturnUrl = Request.QueryString["ReturnUrl"]; // asp.net logon param
        Uri backHereUri = Request.Url; // modify for dev server
        if (!string.IsNullOrEmpty(code)) // user is authenticated
        {
            FacebookUser me = GetUserDetails(code, backHereUri);
            RedirectUser(me.name, "Facebook user");
        }

    if (!string.IsNullOrEmpty(error_description)) // user propably disallowed
    {
        OnError(error_description);
    }
    //fbLogin.Visible = !User.Identity.IsAuthenticated;
    fbLogin.NavigateUrl = string.Format(
        CultureInfo.InvariantCulture,
        "https://www.facebook.com/dialog/oauth?"
        + "client_id={0}&scope={1}&redirect_uri={2}",
        App_ID,
        scope,
        Uri.EscapeDataString(backHereUri.OriginalString));
}
}



FacebookUser GetUserDetails(string code, Uri backHereUri)
{
    Uri getTokenUri = new Uri(
        string.Format(
        CultureInfo.InvariantCulture,
        "https://graph.facebook.com/oauth/access_token?"
        + "client_id={0}&client_secret={1}&code={2}&redirect_uri={3}",
        App_ID,
        App_Secret,
        Uri.EscapeDataString(code),
        Uri.EscapeDataString(backHereUri.OriginalString))
        );
    using (var wc = new WebClient())
    {
        string token = wc.DownloadString(getTokenUri);
        Uri getMeUri = new Uri(
            string.Format(
            CultureInfo.InvariantCulture,
            "https://graph.facebook.com/me?{0}",
            token)
            );
        using (var ms = new MemoryStream(wc.DownloadData(getMeUri)))
        {
            var me = (FacebookUser)userSerializer.ReadObject(ms);
            return me;
        }
    }
}



Получаю ошибку "A socket operation was attempted to an unreachable network 173.252.120.6:443 " в этом месте:
Код: c#
1.
2.
3.
 using (var wc = new WebClient())
        {
            string token = wc.DownloadString(getTokenUri);



Помогите разобраться, что делать
...
Рейтинг: 0 / 0
socket operation was attempted to an unreachable network
    #38625628
carrotik
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
NetCoder,

... так 443-й порт же ... HTTPS ... что-то типа вот так надо, наверное
http://stackoverflow.com/questions/20064505/requesting-html-over-https-with-c-sharp-webclient
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / socket operation was attempted to an unreachable network
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]