Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Experts, I am facing some little Confusion about the Making SEO Friendly URLS

i am writing

HTML
routes.MapPageRoute("-", "-", "~/Jobs/ShowResume.aspx");

in gloabal.asax


C#
foreach (DataListItem item in DataList1.Items)
           {
               if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
               {
                   try
                   {
                       Label lbldate = (Label)item.FindControl("lbldate");
                       string idate = lbldate.Text.Replace("/","-");
                       string date = TimeAgo(Convert.ToDateTime(idate));
                       lbldate.Text = date;
                       HyperLink hreflink = (HyperLink)item.FindControl("hreftitle");
                       hreflink.NavigateUrl = "../-?" + (hreflink.Text).ToString().Trim().Replace(" ", "-");

                   }
                   catch (Exception)
                   {


                   }

               }
           }

after doing this my url is coming

like
http://localhost:55389/NXG-Alpha/-?S/w-In-a-Core-IT-Company[^]


but i want

http://localhost:55389/NXG-Alpha/S/w-In-a-Core-IT-Company[^]


it is possible ?

when i call it it says resources is not found ...
Posted
Updated 23-May-15 7:05am
v2

I think you need to remove the question mark.
C#
"../-?"
 
Share this answer
 
There is a minor correction in your code. See below
C#
foreach (DataListItem item in DataList1.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    try
                    {
                        Label lbldate = (Label)item.FindControl("lbldate");
                        string idate = lbldate.Text.Replace("/","-");
                        string date = TimeAgo(Convert.ToDateTime(idate));
                        lbldate.Text = date;
                        HyperLink hreflink = (HyperLink)item.FindControl("hreftitle");
hreflink.NavigateUrl =(hreflink.Text).ToString().Trim().Replace(" ", "-");                           
                        
                    }
                    catch (Exception)
                    {
                        
                        
                    }
 
                }
            }
 
Share this answer
 
Comments
Aditya Chauhan 26-May-15 9:39am    
Awadesh you r right but if i am sending by this type
page shows an errro Reource not found
Solution Of My problem is



C#
​void Application_BeginRequest(object sender, EventArgs e) {

    string fullOrigionalpath = Request.Url.ToString();

    if (fullOrigionalpath.Contains("/Tour/Inner.aspx?Pid=2&Cid=8")) {
        Context.RewritePath("/Tour/Goa/new-year-goa");
    }
    else if (fullOrigionalpath.Contains("/Tour/Inner.aspx?Pid=2&Cid=8&DeptF=ND")) {
        Context.RewritePath("/Tour/Goa/new-year-goa");
        //This can be something else according to your requirements.
    }
 
Share this answer
 

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