URL REDIRECTION

anil babu

Total Post:19

Points:133
Posted by  anil babu
 1743  View(s)
Ratings:
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 

  1. Arun Singh

    Post:68

    Points:476
    Re: URL REDIRECTION

    Hi Anil Babu,
    I did not get you properly that what are you trying to ask? Could you explain your code in more detail. Check out some following links related ASP.Net URL Routing and URL-Rewriting with Asp.Net, it might be resolve your problem...

    http://mindstick.com/Articles/9992a0bc-90f5-4f04-823a-31f901b61643/?URL%20Routing%20in%20ASP%20Net%203%205%20I

    http://www.codeproject.com/Articles/2538/URL-Rewriting-with-ASP-NET

    http://www.dotnetperls.com/urlmappings

      Modified On Aug-08-2012 07:08:42 AM
  1. anil babu

    Post:19

    Points:133
    Re: URL REDIRECTION

    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
  1. Arun Singh

    Post:68

    Points:476
    Re: URL REDIRECTION

    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));

  1. anil babu

    Post:19

    Points:133
    Re: URL REDIRECTION

    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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!