Home > DeveloperSection > Forums > URL REDIRECTION
anil babu
anil babu

Total Post:19

Points:133
Posted on    August-07-2012 1:16 AM

 ASP.Net ASP.Net 
Ratings:


 4 Reply(s)
 1434  View(s)
Rate this:
Hi,

I am asking one question 

My task is I have  one url like this "http://example.com"

I am passing one parameter alog with url like "http://example.com/Tagid=12345"

I want to display SiteName(ColumnName)in database table value(EX:www.asp.net) correspondind Tagid number

I want to Final Result is

IActual URL is:"http://example.com/Tagid=12345"
I want to open "www.asp.net" this url website corresponding tagId(column)value

I want to display::"http://example.com/?Tagid=12345\www.asp.net"

"www.asp.net" This value comming from DATABASE TABLE

Table Information

Tagid            SiteName

12345            http://www.asp.net

43215            http://www.microsoft.com

54666            http://www.c#corner.com

Give me simple  complete Example 



Arun Singh

Total Post:68

Points:476
Posted on    August-08-2012 7:08 AM


Modified On Aug-08-2012 07:08:42 AM

anil babu
anil babu

Total Post:19

Points:133
Posted on    August-08-2012 6:59 PM

Hi,
My task is I have  one page like this "http://Default.aspx"

I am passing one parameter alog with url like " http://Default.aspx /Tagid=12345"
I am passing parameter Tagid is in DATABASE table column name
I am running That page it will open sitename(column)value corresponding Tagid(column) in browser
For example sitename(column) value in database is www.google.com that google website will open that my task,
based on the tagid chage the out put

I want to display SiteName(ColumnName)in database table value(EX:www.asp.net) correspondind Tagid(column) number

I want to Final Result is

IActual URL is:" http://Default.aspx /Tagid=12345"

I am running that page what value is their that value will open in the browser(For example datatable value is www.asp.net  that ASP.net web site will open)based on Tagid column,change tagid value It will open differently
I want to display::"http://example.com/?Tagid=12345\www.asp.net"

"www.asp.net" This value comming from DATABASE TABLE

Table Information

Tagid            SiteName

12345            http://www.asp.net

43215            http://www.microsoft.com

54666            http://www.c#corner.com

Plz help me I am new this concept

Modified On Aug-08-2012 07:10:40 PM

Arun Singh

Total Post:68

Points:476
Posted on    August-09-2012 2:42 AM

Hi Anil,
I did not get you properly that exactly what do you want but whatever I understood you can resolve this problem by using following code.
If you want to open new web address on the basis of Tagid you can use code like:
        var tagVal = Request.QueryString["Tagid"];
        // fetch your sitename value on the basis of tagVal from the database   
        var con = new SqlConnection("your connection string");
        var cmd = new SqlCommand("select SiteName from tbl_YourTable where Tagid =

'"+tagVal+"'",con);
        con.Open();
        var newUrl = cmd.ExecuteScalar();
        if(Convert.ToString(newUrl)!= String.Empty)
        {
            Response.Redirect(Convert.ToString(newUrl));
        }


If you want to display::"http://example.com/?Tagid=12345\www.asp.net" on web

browser, you can use like following code :

 Response.Redirect(Request.RawUrl + Convert.ToString(newUrl));


anil babu
anil babu

Total Post:19

Points:133
Posted on    August-09-2012 2:56 AM

Sorry,language problem
I have page I am running that page with parameter,
whatever i am passing parameter that corresponding parameter value will disply,
this two values comming from database table
I am passing Tagid=12345 ----------->i want to display corresponding Sitename value(http://www.asp.net) this website will open

I am chenging Tagid= 43215----------->i want to display corresponding Sitename value( http://www.microsoft.com ) this website will open
so on............
This my task
Tagid            SiteName

12345            http://www.asp.net

43215            http://www.microsoft.com

54666            http://www.c#corner.com


Don't want to miss updates? Please click the below button!

Follow MindStick