I face the following problem :
I encrypt my query string then encoding the result so i get url like this :
PageDetail.aspx?enc=LFgzoz6LxQ54RaOMuZCJlluim9oH%2fRW2bpGJEo3rZ7E1Y8ixg9vbHRRc2koFdqbK%2f5PS%2fIv1v%2b3N%2beLwXJMtpdTOEwqwZLoTkh%2bIPW1S4f4764i3MY%2f9AECdSNmIgeaSovpJouXp3bQi4ntOyJOzW4eXawpAvS3gGvPWQLsr0My9NcAd5PT5Qwr2vVOfzjAYc%2f%2f1AdseguQUyWX7sIPK%2fPGYxLmjU204I2bGS%2f8%2fSPCXp4fZfbfJIaafBmSFbRhXAb%2fneWQFb83PzcP7Ljk9o90qMAeVuRvwhAcy6IsPmW76OpwT8JRK8Vw%2fTrmoSDmNCMYN1VuCm%2fT6fvg1mbiruqmPnDoKXr8zR2ChY1zev8leWHWPDmn572Hi02w6nu4vamOSlgIvH2LNEHUYYtIITX1DH%2bSagIl%2fuiNtWsQsdrqd%2b31ksO8GVYuJcAnn7%2fcST4w5Fzs3JPO2cPwiMeXDQw%3d%3d
Then i try to decrypt the result :
but when i try to get the query string through :
Request.QueryString["enc"]
I get null reference exception i don’t know why?
That line of code will not throw a null reference exception because it can’t find the querystring part but because it can’t find the Request object. The QueryString part will just return null if the part you are looking for doesn’t exist.
Likely this is because this code is being written somewhere where the Request object hasn’t been set up (eg application start event). You’ll need to most likely move the code somewhere more suitable. If you believe that you should be able to access the Request object from where you are then you will need to provide us with more details of the context of that line of code.