Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • sudeer 24 posts 42 karma points
    Nov 15, 2012 @ 13:09
    sudeer
    0

    Getting Querystring value in c# from the Url

    how to find the querystring value from a Url. Example

    http://localhost:233/?country=DE

    from this Url how can i get the querystring value. Plaese help me.

    Thanks in advance

     

     

  • Mark Bennett 199 posts 375 karma points
    Nov 15, 2012 @ 14:08
    Mark Bennett
    0

    Sudeer,

    Request.QueryString["country"] should do the job..

    Mark.

  • sudeer 24 posts 42 karma points
    Nov 15, 2012 @ 14:40
    sudeer
    0

    Hi Mark,

    Thanks for your reply.

    If i have the site like http://localhost:233/en/home.aspx?country=DE then i can get by using the code which you had given.

    But My site is running under umbraco.If i ispecify http://localhost:233/?country=DE like this in browser then it is redirecting to http://localhost:233/en/home.aspx with out having querystring.

    I dont know weather umbraco internally rewrites the url and redirect to home.aspx with out having querystring.

    Thanks

    Sudeer

     

  • Mark Bennett 199 posts 375 karma points
    Nov 15, 2012 @ 14:49
    Mark Bennett
    0

    Sudeer,

    What are you actually trying to do? I'm presuming you are trying to set up a multi lingual site?

    Mark.

  • sudeer 24 posts 42 karma points
    Nov 15, 2012 @ 14:59
    sudeer
    0

    Mark,

    Yes thats true. I am trying to read the querystring from this Url

    http://localhost:233/?country=DE

  • Mark Bennett 199 posts 375 karma points
    Nov 15, 2012 @ 15:16
    Mark Bennett
    0

    Sudeer,

    Have you had a look at this post about setting up multilingual sites - it seems to be the proper way of doing multilingual sites in Umbraco - it may save you a lot of hassle doing it this way.

    Mark.

  • fatmazayed 41 posts 123 karma points
    Apr 25, 2023 @ 22:46
    fatmazayed
    1

    you can flow that link

    @inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
    

    @{ var url = HttpContextAccessor.HttpContext.Request; string currentURL = string.Concat(url.Host, url.Path,"item="); var serviceItemSelected = HttpContextAccessor.HttpContext.Request.Query["item"]; }enter code here

    access qury string

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies