3

How I can get specific values from the following URL I need to get only 3 values

http://earnprofitclickint.com/UserWorking/Successfull.aspx?lr_paidto=U9925362&lr_amnt=2.00&lr_currency=LRUSD&lr_store=http%3A%2F%2Fwww.earnprofitclickint.com&lr_merchant_ref=&lr_paidby=U3563444&lr_fee_amnt=0.00&lr_transfer=143636187&lr_timestamp=2013-12-05+18%3A31%3A33&ctl00%24contentplaceholder1%24amount=&ctl00%24contentplaceholder1%24id=70&ctl00%24contentplaceholder1%24txtamount=+2&ctl00%24contentplaceholder1%24username=networker&lr_encrypted=04E20ADA982A2AF9C1C64DB3C1601BA596373E22D7B4D21813A51C43DC0198CD&lr_encrypted2=59C8269D431F915360F3B8179EC95181D8C458AB91D72AF3DFC1DC0DFDAC4F64

I want to get 3 values from the above URL return from Liberty Reserve Website and want to insert these three values to database using LINQ TO SQL

I need to get the following values

r_amnt=2.00 ID=70 username=networker

I have written the code in page load to get the above values when the response come and Redirect to my successful page:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        ID.Value = Request.QueryString["id"].ToString();
        UserName.Value = Request.QueryString["username"].ToString();
        Amount.Value = Request.QueryString["lr_amnt"].ToString();

        SaveLocalHistory();
        Divmessage.Visible = true;
    }
}

public void SaveLocalHistory()
{
    MLMDataContext db = new MLMDataContext();

    UsersInvestement pd = new UsersInvestement();
    pd.Amount = Convert.ToDouble(Amount.Value);
    pd.UserId = Convert.ToInt32(ID.Value);
    pd.UserName = UserName.Value;
    pd.Description = "This amount has been received From LR";
    pd.IncomeTypeId = 4;
    pd.CreatedDate = DateTime.Now.Date;
    db.UsersInvestements.InsertOnSubmit(pd);
    db.SubmitChanges();
}

This is a manual change in the URL:

http://earnprofitclickint.com/UserWorking/Successfull.aspx?lr_paidto=U9925362&lr_amnt=2.00&lr_currency=LRUSD&lr_store=http%3A%2F%2Fwww.earnprofitclickint.com&lr_merchant_ref=&lr_paidby=U3563444&lr_fee_amnt=0.00&lr_transfer=143636187&lr_timestamp=2013-12-05+18%3A31%3A33&ctl00%24contentplaceholder1&amount=&ctl00%24contentplaceholder1&id=70&ctl00%24contentplaceholder1%24txtamount=+2&ctl00%24contentplaceholder1&username=networker&lr_encrypted=04E20ADA982A2AF9C1C64DB3C1601BA596373E22D7B4D21813A51C43DC0198CD&lr_encrypted2=59C8269D431F915360F3B8179EC95181D8C458AB91D72AF3DFC1DC0DFDAC4F64


If I change it manually then it works. Any idea?

6
  • Any help will be appriciated thanks Commented May 12, 2013 at 19:46
  • Thanks for your help: i have done according to the above but it just get one querysting Amount.Value = Request.QueryString["lr_amnt"].ToString(); value not the other it gives error i think due to empty spaces before username and id the URL CAN anyone help me out thanks alot Commented May 14, 2013 at 6:10
  • i have updated the code like ID.Value = Request.QueryString["id"].ToString(); UserName.Value = Request.QueryString["username"].ToString(); Amount.Value = Request.QueryString["r_amnt"].ToString(); Commented May 14, 2013 at 6:10
  • when i changed the url manually then it works and remove the %24 Commented May 14, 2013 at 6:31
  • earnprofitclickint.com/UserWorking/… Commented May 14, 2013 at 6:31

2 Answers 2

1

Your parameter names are not username and id, they are ctl00$contentplaceholder1$username for username and ctl00$contentplaceholder1$id for id

Since %24 when URLDecode gives $ , you need to do the corresponding replacements too.

Try this:

ID.Value = Request.QueryString["ctl00$contentplaceholder1$id"].ToString();
UserName.Value = Request.QueryString["ctl00$contentplaceholder1$username"].ToString();
Amount.Value = Request.QueryString["r_amnt"].ToString();

and it should work. Let me know otherwise! :)

Sign up to request clarification or add additional context in comments.

3 Comments

Let me know if it does not, there is one more thing that might be a problem. I'll get it sorted in-case this does not work.
Thanks sunny Rgupta for the help: when i use as you mentioned above it again gives nullable exception so i copies this %24 to notepad and view and came to know that this was $ sign so i have updated it like ID.Value = Request.QueryString["ctl00$contentplaceholder1$id"].ToString(); UserName.Value = Request.QueryString["ctl00$contentplaceholder1$username"].ToString(); Amount.Value = Request.QueryString["lr_amnt"].ToString(); and it works thanks for your best idea.
That is exactly what I had in mind when I said there could be another problem.
0

I am fairly certain that the query string values are case sensitive, meaning that this code

ID.Value = Request.QueryString["ID"].ToString();
UserName.Value = Request.QueryString["UserName"].ToString();
Amount.Value = Request.QueryString["lr_amnt"].ToString();

should probably be in this form

ID.Value = Request.QueryString["id"].ToString();
UserName.Value = Request.QueryString["username"].ToString();
Amount.Value = Request.QueryString["r_amnt"].ToString();

if you wanted to pull out "r_amnt=2.00 id=70 username=networker"


As an aside, note that you never dispose of your database context. This can be dangerous in that it is possible your connection will not close for a very long time, I would suggest doing this instead:

using( MLMDataContext db = new MLMDataContext() )
{
 UsersInvestement pd = new UsersInvestement();
 pd.Amount = Convert.ToDouble(Amount.Value);
 pd.UserId = Convert.ToInt32(ID.Value);
 pd.UserName = UserName.Value;
 pd.Description = "This amount has been received From LR";
 pd.IncomeTypeId = 4;
 pd.CreatedDate = DateTime.Now.Date;
 db.UsersInvestements.InsertOnSubmit(pd);
 db.SubmitChanges();
}

The using statement ensures that Dispose is called on the DataContext (which inherits from IDisposable) and will properly close the connection once the actions complete.

2 Comments

Thanks for your help: i have done according to the above but it just get one querysting Amount.Value = Request.QueryString["lr_amnt"].ToString(); value not the other it gives error i think due to empty spaces before username and id the URL CAN anyone help me out thanks alot
i have updated the code like ID.Value = Request.QueryString["id"].ToString(); UserName.Value = Request.QueryString["username"].ToString(); Amount.Value = Request.QueryString["r_amnt"].ToString();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.