如何使用锚标签标题作为网址 [英] How can use anchor Tag title as a url address

查看:45
本文介绍了如何使用锚标签标题作为网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好专家,我正面临着制作SEO友情网址的一些小困惑



i我正在写作



 routes.MapPageRoute( - , - ,〜/ Jobs / ShowResume.aspx); 



in gloabal.asax





  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 (例外)
{


}

}
}



这样做之后我的网址即将来临



喜欢

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





但我想要



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





有可能吗?



当我打电话给它说资源没找到...

解决方案

我认为你需要删除问号。

   ../   - ? 


您的代码中有一个小的更正。见下文

  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 (例外)
{


}

}
}


解决我的问题是







 void Application_BeginRequest( object  sender,EventArgs e) {

string fullOrigionalpath = Request.Url.ToString();

if (fullOrigionalpath.Contains( / Tour / Inner.aspx?Pid = 2& Cid = 8)){
Context.RewritePath( /游览/果阿/新年果阿);
}
else if (fullOrigionalpath.Contains( / Tour / Inner.aspx?Pid = 2& Cid = 8& DeptF = ND)){
Context .RewritePath( / Tour / Goa / new-year-goa);
// 根据您的要求,这可能是其他内容。
}


Hello Experts, I am facing some little Confusion about the Making SEO Friendly URLS

i am writing

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


in gloabal.asax


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 ...

解决方案

I think you need to remove the question mark.

"../-?"


There is a minor correction in your code. See below

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)
                    {
                        
                        
                    }
 
                }
            }


Solution Of My problem is



​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.
    }


这篇关于如何使用锚标签标题作为网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆