当前位置:编程学习 > C#/ASP.NET >>

如何取得最新添加的id来生静态

我在做一个新闻系统,要生成静态文件,请问要怎么做才能取得最新发表的文章,因为要马上生成静态,如果有两人同时在发表怎么办?急啊.谢谢各位. --------------------编程问答-------------------- 最新的啊,有时间管着啊
新闻表有时间啊,有提交时间啊
在同时也会有区别啊 --------------------编程问答-------------------- 谢谢不过还是不大明白.我是根据url来生成的. --------------------编程问答-------------------- 根据发布时间,取回发布新闻的ID --------------------编程问答-------------------- 谢谢.我试一下. --------------------编程问答-------------------- public void ProcessRequest(HttpContext context)
        {
             string requestedPath = context.Request.Url.PathAndQuery;
            string physicalPath = context.Request.PhysicalPath;
            string appPath = context.Request.ApplicationPath;
            string path = context.Request.Path;
            string query = context.Request.QueryString.ToString();


            // get the configuration rules
            StaticPageRuleCollection rules = StaticPageConfiguration.GetConfig().Rules;

            // iterate through each rule...
            for (int i = 0; i < rules.Count; i++)
            {
                // get the pattern to look for, and Resolve the Url (convert ~ into the appropriate directory)
                string htmlPattern = "^" + StaticPageUtils.ResolveUrl(appPath, rules[i].LookFor) + "$";

                // Create a regex (note that IgnoreCase is set...)
                Regex re = new Regex(htmlPattern, RegexOptions.IgnoreCase);
                if (re.IsMatch(requestedPath))
                {
                    // match found - do any replacement needed
                    string sendToUrl = StaticPageUtils.ResolveUrl(appPath, re.Replace(requestedPath, rules[i].SendTo));
                    string htmlPath = context.Server.MapPath(sendToUrl);

                    //需要生成静态页面
                    if (!File.Exists(htmlPath))
                    {
                        //静态页面不存在
                        context.Response.Filter = new Filter(context.Response.Filter, htmlPath);
                        
                    }
                    else
                    {
                        //静态页面存在
                        FileInfo file = new FileInfo(htmlPath);
                        DateTime now = DateTime.Now;
                        double span = (int)TimeSpan.FromTicks(now.Ticks - file.LastWriteTime.Ticks).TotalMinutes;
                        double timeSpan = rules[i].TimeSpan;
                        if (span >= timeSpan && timeSpan > 0)
                        {
                            //过期
                            context.Response.Filter = new Filter(context.Response.Filter, htmlPath);
                        }
                        else
                        {
                            //未过期
                            context.Server.Transfer(sendToUrl);
                        }
                    }
                    break;
                }
            }

            context.RewritePath(path, null, query);
            PageParser.GetCompiledPageInstance(path, physicalPath, context).ProcessRequest(context);

利用IHttpHandler自动生成HTML 
不需要做这么麻烦的处理。。
        } --------------------编程问答--------------------

--MSSQL的话,可以用
select @@IDENTITY AS NewID from test
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,