URLEncode Problem from ASP.NET

V

vtreddy

Hi All:
In my application I am sending the input values through query string from a datagrid template column,I used URLEncode to encode the URL String,
please find the input below, I am facing a problem when the input string contains ® character ,
Here from ASP.NET I am redirecting to the ASP based system,when I give same input from ASP based system, it is showing Microsoft%AE%20Access%20 ,with this I am getting the correct results, where as when I send it from the ASP.NET with URL Encode it is showing Microsoft%c2%ae+Access, this is not giving any results. Can any one please help me out what to do to get the URL string simillar to I got it in ASP. Is there any different way to handle the encoding when ® character present in the string.


Input:
Microsoft® Access
My Code:
<asp:TemplateColumn HeaderText="Sample Column">
<ItemTemplate>
<asp:Hyperlink runat="server" Text='<%#(string)DataBinder.Eval(Container.DataItem,"ProductName")%>' NavigateUrl='<%# "http://trwork/SMSReporting_TRS/Report.asp?ReportID=67&amp;variable="+Server.UrlEncode((string)DataBinder.Eval(Container.DataItem,"ProductName"))%>' ID="Hyperlink1"/>
</ItemTemplate>
</asp:TemplateColumn>

From ASP URL String :
http://trwork/SMSReporting_TRS/Report.asp?ReportID=67&variable=Microsoft%AE%20Access%20

From ASP.NET URL String:
http://trwork/SMSReporting_TRS/Report.asp?ReportID=67&variable=Microsoft®+Access

Thanks in Advance
 
B

Bret Mulvey [MS]

Hi All:
In my application I am sending the input values through query string from a datagrid
template column,I used URLEncode to
encode the URL String, please find the input below, I am facing a problem when the input
string contains ® character , Here from ASP.NET I am redirecting to the ASP based
system,when I give same input from ASP based system, it is showing
Microsoft%AE%20Access%20 ,with this I am getting the correct results, where as when I
send it from the ASP.NET with URL Encode it is showing Microsoft%c2%ae+Access,
this is not giving any results. Can any one please help me out what to do to get the URL
string simillar to I got it in ASP. Is there any different way to handle the encoding when ®
character present in the string.

%C2%AE is the UTF-8 encoding for the (R) character. Your ASP page was
probably using CodePage="1252" or something like that, which is a Latin 1
codepage. The (R) character is %AE in that codepage.

To get your ASP.NET page to behave the same way, try setting
Response.Charset and Response.ContentEncoding:

Response.Charset = "iso-8859-1"; // Latin 1
Response.ContentEncoding = System.Text.GetEncoding(Response.Charset);

Another way to fix this is to change the Report.asp page so that it
understands Unicode. This will allow your application to use characters from
more than just the Latin 1 character set. I think you can do this by setting
CodePage="65001" on your Report.asp page but I'm not sure.
 
V

vtreddy

Bret,

Thank you very much for your help, Session.CodePage = 65001 is commented out in asp based reporting system, when I uncommented the code,It worked fine.

Best Regards,

Thirupathi
 
V

vtreddy

Bret,

When I Set the CodePage="65001", I am getting the results,the Query string is decoded properly, please find below the output, but in the result,it is adding  character before ® character,Could you please let me know, How to encode the string to avoid  here.

Parameters: Microsoft® Access
Computer Name User Name Product Name Company Name Product Version
TRWORK Administrator Microsoft® Access Microsoft Corporation 3.00.0002

Thank you very much for your help.

Thirupathi

Bret,

Thank you very much for your help, Session.CodePage = 65001 is commented out in asp based reporting system, when I uncommented the code,It worked fine.

Best Regards,

Thirupathi
 
B

Bret Mulvey [MS]

It's possible that the ASP page is interpreting the string correctly now and
is rendering the page using UTF-8, but the browser is not interpreting the
page as UTF-8. If you're using IE, check to see what "View / Encoding" says
the page is set to. If it's not Unicode, check to see if the page has a
<meta name="content-type" content="text/html; charset=utf-8" /> tag. If it
includes this tag but shows iso-8859-1 or some other charset value, try
changing it to utf-8. You can play with different values of View / Encoding
in the browser to determine which encoding the server actually used for the
page output.


Bret,
When I Set the CodePage="65001", I am getting the results,the Query string
is decoded properly, please find below the output, but in the result,it is
adding  character before ® character,Could you please let me know, How to
encode the string to avoid  here.
Parameters: Microsoft® Access
Computer Name User Name Product Name Company Name Product Version
TRWORK Administrator Microsoft® Access Microsoft Corporation
3.00.0002
Thank you very much for your help.
Thirupathi
Bret,

Thank you very much for your help, Session.CodePage = 65001 is commented out
in asp based reporting system, when I uncommented the code,It worked fine.

Best Regards,

Thirupathi
 
V

vtreddy

Bret,
I changed to utf-8, it is displaying the results correctly,
Thank you very much for your help,
Best Regards,
Thirupathi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top