2014年7月13日 星期日

[RESOLVED] Linkbutton string not working when there is & in the company name


in my asp.net+vb web i am  using one linkbutton. by this i used to browse the details of company



PostBackUrl="unitlink.aspx?unit=TATA Motors">Tata Motors



PostBackUrl="unitlink.aspx?unit=L&T">L&T


The first linkbutton woks fine and when i click on thhe second one iit doesn't work i checked a lot it is because there is & inthat company name how can be it solved



You should use UrlEncode and UrlDecode


Those methods should be used any time you're inserting user inputted data into the query string.



Hi,


Try adding this to your web.config if you are using .NET 4.0:


system.web>
requestValidationMode="2.0"
requestPathInvalidCharacters="<,>,*,%,:,&,\"
relaxedUrlToFileSystemMapping="true"
/>
...






...

And please refer the blog


http://www.christophercrooker.com/use-any-characters-you-want-in-your-urls-with-aspnet-4-and-iis


http://www.hanselman.com/blog/ExperimentsInWackinessAllowingPercentsAnglebracketsAndOtherNaughtyThingsInTheASPNETIISRequestURL.aspx


Hope it can help you.


沒有留言:

張貼留言