简体   繁体   中英

The redirect_uri URL must be absolute error

what i am trying to do is redirecting the user if it's access token is expired i am doing this using my localhost like this :

Response.Redirect("https://www.facebook.com/dialog/oauth?" +
           "client_id=" + "{507061112747022}" +
           "&redirect_uri=" + "{http://localhost:63695/FacebookChatApi/Default.aspx}");

but the error is occurring saying The redirect_uri URL must be absolute error what would be the problem ? and how can i fix it ( i am using c# as language )

Remove the curly braces.

Url encode the redirect URI.

Response.Redirect("https://www.facebook.com/dialog/oauth?" +
   "client_id=507061112747022" +
   "&redirect_uri=" + 
   Uri.EscapeDataString("http://localhost:63695/FacebookChatApi/Default.aspx"));

You can also try to set the string as a lit

with appending @ to the start of your response.redirect

so it would look like

Response.Redirect(@"https://www.facebook.com/dialog/oauth?" +    
       "client_id=" + "{507061112747022}" +
       "&redirect_uri=" + "{http://localhost:63695/FacebookChatApi/Default.aspx}");

as Spender said below you could also encode as a URI

Uri uri = new Uri("https://www.facebook.com/dialog/oauth?" +    
           "client_id=" + "507061112747022" +
           "&redirect_uri=" + "http://localhost:63695/FacebookChatApi/Default.aspx");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM