get querystring value in mvc

Asked By ankita
09-Sep-10 03:17 AM
Earn up to 0 extra points for answering this tough question.
I have made one mvc application in which i have used urlrewriting but when i want to access querystring so i cannot get the value of querystring.
it is like below

CompanyDetails?CompanyID=C000000015
in which companyDetails is the page name which is of aspx page and i want to get the value of CompanyID

i wrote below syntax
Request.QueryString["CompanyID"].ToString()
but i dont get the value.

  re: get querystring value in mvc

Goniey N replied to ankita
09-Sep-10 03:40 AM
-- Some Changes Are Required :

-- Write "aspx" page & Value In Double Quotes....

CompanyDetails.aspx?CompanyID="C000000015"

-- Store In Some String Variable...
string CompId= Request.QueryString["CompanyID"].ToString()


Finally Your Code :

01.//Code Bhind Of Source Page....
02. 
03.private void BtnGo_Click (object sender, System.EventArgs e)
04.{
05.  string URL;
06.  //Store Whole Querystring Into The URL String Variable...
07.  URL="CompanyDetails.aspx?CompanyID="C000000015";
08.  Response.Redirect(URL);
09.}
10. 
11. 
12. 
13.//Code Behind Of CompanyDetails.aspx Page....
14.private void Page_Load (object sender, System.EventArgs e)
15.{
16.  //Store Value Of CompanyID Into LblCompId Lable
17.  LblCompId.Text=Request.QueryString["CompanyID"];
18.}



-- For More Details See My FAQ - How To Use Query String?

-- hope This Will Work At Your Side.....

  re: get querystring value in mvc

Thiyagu S replied to ankita
09-Sep-10 03:40 AM
companydetail is name of the webform????????

      if it is then give like this companydetail.aspx

  re: get querystring value in mvc

ankita replied to Thiyagu S
09-Sep-10 06:00 AM
YEs but its url routing so it wont show the aspx.It will show only webform name
Create New Account