string.AddQueryString(string)

Here are the examples of the csharp api class string.AddQueryString(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

9 Examples 7

1. Example

View license
private new HttpResponseMessage Get(String token = null)
        {
            var parameters = new NameValueCollection();

            if (token.IsPresent())
            {
                parameters.Add("token", token);
            }

            var url = TestUrl.AddQueryString(parameters.ToQueryString());
            return base.Get(url);
        }

2. Example

View license
private HttpResponseMessage Get(String token = null, String clientId = null)
        {
            var parameters = new NameValueCollection();

            if (token.IsPresent())
            {
                parameters.Add("token", token);
            }

            if (clientId.IsPresent())
            {
                parameters.Add("client_id", clientId);
            }

            var url = TestUrl.AddQueryString(parameters.ToQueryString());
            return base.Get(url);
        }

3. Example

View license
public SignOutMessage CreateSignoutMessage(ValidatedEndSessionRequest request)
        {
            var message = new SignOutMessage();
            
            if (request.Client != null)
            {
                message.ClientId = request.Client.ClientId;

                if (request.PostLogOutUri != null)
                {
                    message.ReturnUrl = request.PostLogOutUri;
                }
                else
                {
                    if (request.Client.PostLogoutRedirectUris.Any())
                    {
                        message.ReturnUrl = request.Client.PostLogoutRedirectUris.First();
                    }
                }

                if (request.State.IsPresent())
                {
                    if (message.ReturnUrl.IsPresent())
                    {
                        message.ReturnUrl = message.ReturnUrl.AddQueryString("state=" + request.State);
                    }
                }
            }

            return message;
        }

4. Example

Project: IdentityServer3
Source File: LogoutResult.cs
View license
private HttpResponseMessage Execute()
        {
            Logger.Info("Redirecting to logout page");

            var url = env.GetIdentityServerBaseUrl() + Constants.RoutePaths.Logout;

            if (message != null)
            {
                var cookie = new MessageCookie<SignOutMessage>(this.env, this.options);
                var id = cookie.Write(this.message);

                url = url.AddQueryString("id=" + id);
            }

            var uri = new Uri(url);

            var response = new HttpResponseMessage(HttpStatusCode.Redirect);
            response.Headers.Location = uri;
            return response;
        }

5. Example

View license
internal static IEnumerable<LoginPageLink> Render(this IEnumerable<LoginPageLink> links, string baseUrl, string signinId)
        {
            if (links == null || !links.Any()) return null;

            var result = new List<LoginPageLink>();
            foreach (var link in links)
            {
                var url = link.Href;
                if (url.StartsWith("~/"))
                {
                    url = url.Substring(2);
                    url = baseUrl + url;
                }

                url = url.AddQueryString("signin=" + signinId);

                result.Add(new LoginPageLink
                {
                    Type = link.Type,
                    Text = link.Text,
                    Href = url
                });
            }
            return result;
        }

6. Example

View license
HttpResponseMessage Execute()
        {
            var responseMessage = new HttpResponseMessage(HttpStatusCode.Redirect);
            var url = _response.RedirectUri;

            var query = _response.ToNameValueCollection().ToQueryString();

            if (_response.Request.ResponseMode == Constants.ResponseModes.Query)
            {
                url = url.AddQueryString(query);
            }
            else
            {
                url = url.AddHashFragment(query);
            }

            responseMessage.Headers.Location = new Uri(url);

            if (_response.IsError)
            {
                Logger.Info("Redirecting to: " + url);
            }
            else
            {
                Logger.Info("Redirecting to: " + _response.RedirectUri);
            }

            return responseMessage;
        }

7. Example

View license
IHttpActionResult RedirectToLogin(SignInMessage message, NameValueCollection parameters)
        {
            message = message ?? new SignInMessage();

            var path = Url.Route(Constants.RouteNames.Oidc.Authorize, null).AddQueryString(parameters.ToQueryString());
            var host = new Uri(Request.GetOwinEnvironment().GetIdentityServerHost());
            var url = new Uri(host, path);
            message.ReturnUrl = url.AbsoluteUri;

            return new LoginResult(Request.GetOwinContext().Environment, message);
        }

8. Example

View license
private async Task<IEnumerable<string>> GetClientEndSessionUrlsAsync()
        {
            // read client list to get URLs for client logout endpoints
            var clientIds = _clientListCookie.GetClients();

            // Fetch the Clients for each clientid
            var clients = new List<Client>();
            foreach (var clientId in clientIds)
            {
                var client = await _clientStore.FindClientByIdAsync(clientId);

                if (client != null)
                {
                    clients.Add(client);
                }
            }

            // get user's session id. session id will possibly 
            // be needed below to pass to client's endpoint
            var sid = _sessionCookie.GetSessionId();

            var urls = new List<string>();
            foreach (var client in clients)
            {
                if (client.LogoutUri.IsPresent())
                {
                    var url = client.LogoutUri;

                    // add session id if required
                    if (client.LogoutSessionRequired)
                    {
                        url = url.AddQueryString(Constants.ClaimTypes.SessionId + "=" + sid);
                    }

                    urls.Add(url);
                }
            }

            return urls;
        }

9. Example

View license
private IHttpActionResult CreateConsentResult(
            ValidatedAuthorizeRequest validatedReques/n ..... /n //View Source file for more details /n }