Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have couple of strings and they are encoded using below code

C#
protected void page load()
{
DataTable dt = new DataTable();
               
 dt.Columns.Add("a");
 dt.Columns.Add("b");
 dt.Columns.Add("c");
 dt.Columns.Add("d");
 dt.Columns.Add("e");
 dt.Columns.Add("f");
              
 dt.Rows.Add("value1","value2","value3","value4");

 byte[] ba = ConvertToBytes(dt);

 string data = Convert.ToBase64String(ba);
 string dataEncoded = Server.UrlEncode(data);

Response.Redirect("http://www.project.com/page1.aspx?q=" + dataEncoded, false)

}


  public static byte[] ConvertToBytes(Object obj)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                BinaryFormatter bf = new BinaryFormatter();
                bf.Serialize(ms, obj);
                return ms.ToArray();
            }
        }


What I have tried:

The code is encoding and it is redirecting to the page specified in response.redirect .
but after redirecting it is showing 404 file or directory not found error,

but the Page1.aspx is active in live.
if i have omitted the query string and redirects the page it is loading correctly.

can someone help me regarding this
Posted
Updated 11-Dec-18 0:39am
v2
Comments
Afzaal Ahmad Zeeshan 11-Dec-18 6:35am    
That is because the page where you are trying to redirect to does not exist, or expects something extra in the URL to be able to process the request.

Did you consider checking all that out?
Member 13142345 11-Dec-18 7:42am    
Yes the page is active and all the parameters to redirect is also there in that page

1 solution

As you have already mentioned in your question, this problem occurs when you are using query string and URL rewrite is unable to process that. That is also mentioned in Microsoft's documentation, URL Rewrite Module Configuration Reference | Microsoft Docs[^]. You might have missed the QUERY_STRING configuration in your mappings in web.config file; did you?

Also a similar thread from SO: IIS URL Rewrite not working with query string - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900