Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

It appears to be a simple query, however, I am sending a link to user with query string values. Once user access this link, fills in the details and submits the form, I am collecing the data submitted along with the query stirng.

Problem being Query string values are always null.

I have tried accessing it throuhg request, request.querystring , http context etc. Nothing works. Any idea?

What I have tried:

C#
public class HomeController : Controller
{
  public ActionResult Index()
  {
    // Code to Generate a link and sending email.
    // Link is of aformat http://localhost:1234/HomeController/Index1? 
       name=xyx&eamil=xyz@mail.com

    return View();
  }
[httpGet] 
public ActionResult Index1()
  {
    
    return View();
  }
[httpPost] 
public ActionResult Index1(string name,string email,formCollection collection)
  {
   // Name and email here are always null while I get the avalues in form collection,
    return View();
  }

}
Posted
Updated 31-Jul-20 22:21pm
v3

1 solution

If you have type this link
http://localhost:1234/HomeController/Index1?name=xyx&eamil=xyz@mail.com
into your browser.

This action method inside your controller can catch that link above.
[HttpGet]
public ActionResult Index1(string name, string email)
{
  //get the values of name, email 
  return View();
}


Hope this helps.

Cheers,
Jin
 
Share this answer
 
v2

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