Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 880439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:05:54+00:00 2026-05-15T12:05:54+00:00

I want to see if my encoding is working however the example I made

  • 0

I want to see if my encoding is working however the example I made just reverts back to non encoded after it goes back to the page.

<a href="http://search.msn.com/results.aspx%3fq%3dIamBad">Click Here!</a>

Turns back into

<a href="http://search.msn.com/results.aspx?q=IamBad">Click Here!</a>

Edit

UrlEncode Untrusted input is used in a
URL (such as a value in a
querystring) Click
Here!

http://msdn.microsoft.com/en-us/library/aa973813.aspx

So my question is I am trying to see if something is not working right(ie why does it make the query string part look normal again).

Is it because the query string contains nothing really out of the ordinary. Or is something re encoding it back to its original form?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:05:54+00:00Added an answer on May 15, 2026 at 12:05 pm

    You simply do not redisplay inputs from a user that come in via a form submission or through the query string, either redisplaying it to that user directly or storing it in a database that would then display it to other users of the site.

    Say you have a hyperlink like this

    /default.aspx?message=%3cscript%3ealert('Hello+world')%3b%3c%2fscript%3e
    

    What you do not want to do is this

    string message = Request.QueryString["message"];
    if (!string.IsNullOrEmpty(message))
        directlyDisplayedLiteral.Text = message; 
    

    Because what would happen is that when that when the page loads, the user is going to see a message box pop up on screen. All this script produces is a stupid little message box, but it could be doing other malicious things to your users.

    Instead, you want to encode the input before displaying it, so it becomes something harmless.

    string message = Request.QueryString["message"];
    if (!string.IsNullOrEmpty(message))
        directlyDisplayedLiteral.Text = Server.HtmlEncode(message); 
    

    So all that happens is that <script>alert('Hello world');</script> is written to the screen, which is actually &lt;script&gt;alert('Hello world');&lt;/script&gt; in HTML. There’s no message box, no script actually executing, it’s just benign text on a screen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want see the source code of System.Web.Routing.RouteValueDictionary class. But Reflector can't disassemble it
I want to see if a time I read from a db overlaps with
I want to see a list of all changes the next push would do.
I want to see the source of functions like ns_initparse(), res_search() etc. Where can
I want to see class, function and variable/property, dependencies visually, like NDepend , but
I want to see how my #include files be processed when Microsoft Visual Studio
I want to see how many rows my delete query effects so I know
I want to see how g++ lays out memory for classes and virtual tables.
I want to see how much is taken by the C program, so I
I want to see the actual commands sent to g++ during a Code::Blocks build.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.