Click here to Skip to main content
12,507,343 members (64,294 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET C#4.0
in my web application i have 2 dropdowns for categories...in a button click i need to bind the url from database corresponding to the selected categories...

For example

my url----> http://localhost:1232/tollfree.aspx

im selecting category1 as ---->Jewellery Shops
category2 as ---->ABC Diamonds

after button click my url should be

http://localhost:1232/tollfree.aspx/abc-diamonds-toll-free-number

how can i bind this url from database???
Posted 21-Feb-13 22:15pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this:
string AddValue = "abc-diamonds-toll-free-number"; //Suppose "abc-diamonds-toll-free-number" is coming from database.
stirng absoluteURL = Request.Url.AbsoluteUri + "/" + AddValue;

Now you can redirect your application to absoluteURL.
Use:
Response.Redirect(absoluteURL);

--Amit
  Permalink  
Comments
sundarpks 22-Feb-13 4:56am
   
Thanks Amit 4 ur reply

but if do another search url gets added like tis...

http://localhost:1232/tollfree.aspx/abc-diamonds-toll-free-number/xyz-gold-toll-free-number
_Amy 22-Feb-13 5:03am
   
Welcome. :)
Everytime you need to clear the string absoluteURL after using it.
absoluteURL = "";

--Amit
sundarpks 22-Feb-13 5:17am
   
i hv already tried this...

AbsoluteUri gets changed after submission...so wen v add our database driven url to this AbsoluteUri it goes on adding.....
_Amy 22-Feb-13 5:20am
   
Oh! I missed that one. First time store Request.Url.AbsoluteUri in session/hidden field. And every time take it from session/hidden field.

--Amit
sundarpks 22-Feb-13 5:37am
   
ya i too thought of tat....but wat i exactly need is like url rewriting from database in which v can use tat url in future.... jus like search engines....
_Amy 22-Feb-13 5:53am
   
Then take a look at these links:
URL Rewriting with ASP.NET[^]
URL Rewriting in ASP.NET[^]
sundarpks 22-Feb-13 6:19am
   
Thanks Amit for ur replies....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100