English 中文(简体)
ASP.NET 数据库中的元数据
原标题:ASP.NET MetaTags from database

我正在开发一个网站,使网站管理员能够把MetaTags更改为网站一厘米,并将MySql数据库中的MetaTags储存起来。

在公开主编中,在<代码>Page_Load活动中,我从数据库中获取这些元数据。

sTitle = get_from_data_base();

using (HtmlMeta mTag = new HtmlMeta())
{ 
    mTag .Name = "Title"; 
    mTag .Content = sTitle; 
    Page.Header.Controls.Add(mTag); 
}

这个问题每当一个页数,即总经理的负荷活动。 网页从数据库上载到这些梅塔格斯。

在装满后,我怎么能够保持切合点或类似于 met合点,以便网站能够按要求进入数据库?

该网站如何知道这些梅塔格斯何时改变装船?

请举例说明。

非常感谢。

最佳回答

这方面的一个解决办法是,把数据装上全球一次。 作为轴心申请启动活动,并在每一页添加结果,要求从申请物体上装载。

当数据在数据库中发生变化时,查阅申请标语并更新。

如果你不知道如何处理全球问题。 作为轴心或申请标的,即代号。

void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            string sTitle = get_from_data_base();
            Application.Add("sTitle", sTitle);

        }
        public string get_from_data_base()
        {
            //update this to call the database and get the data
            return "Your data";
        }

在您的网页上写道:

string sTitle = Application["sTitle"].ToString();
            using (HtmlMeta mTag = new HtmlMeta())
            {
                mTag.Name = "Title";
                mTag.Content = sTitle;
                Page.Header.Controls.Add(mTag);
            }

虽然您的管理工作正在更新标的如下线:

Application["sTitle"] = "You manager entered string";
问题回答

最后,在您的答复和互联网读物之后,我去了Cache物体,而是申请标语。 我读得较好,因此,我最后提出,这是为了在全球类别上添加这一内容,并从我的主人那里获得这一方法。 文件

    public static MetaTagsDN get_meta_tags()
    {
        MetaTagsDN oTags;

        if (HttpRuntime.Cache["MetaTags"] == null)
        {
            MetaTagsLN ln = new MetaTagsLN();
            oTags = ln.get_metatags();

            HttpRuntime.Cache["MetaTags"] = oTags;
        }
        else
        {
            oTags = (MetaTagsDN)HttpRuntime.Cache["MetaTags"];
        }

        return oTags;
    }

What do you think?

感谢我......





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签