zoukankan      html  css  js  c++  java
  • Url ReWriting

     

    这个由微软提供的组件已经编译好了的,无需自己再写代码,直接用就行
    对于Web.Config设置一下:

    节最开始加上:

      <configSections>
        
    <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
      
    configSections>

    节中加上:

    <RewriterConfig>
     
    <Rules>
       
    <RewriterRule>
       
    <LookFor>~/News,(d{4}),(d{1,2}),(d{1,2}),(d{1,9}).aspxLookFor>
       
    <SendTo>~/news_view.aspx?newsid=$4SendTo>
      
    RewriterRule>
      
    <RewriterRule>
       
    <LookFor>~/(d{4})/(d{2})/Default.aspxLookFor>
       
    <SendTo>~/news_view.aspx?year=$1&month=$2]]>SendTo>
      
    RewriterRule>
     
    Rules>
      
    RewriterConfig>

      
    节加上:
     

     <httpModules>
      
    <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
     
    httpModules>

    处理一下链接:

    news.aspx

    private void Page_Load(object sender, System.EventArgs e)
      
    {
       
    // 在此处放置用户代码以初始化页面
       DataTable dt=new DataProvider().GetNewsToIndexPage(1);
       
    //格式化URL
       UrlFormat formats=new UrlFormat();

       lbNews.Text 
    = "
      ";
         
      if (dt.Rows.Count>0)
         
      {
          
      int counter=0;
          
      while (counter < dt.Rows.Count)
          
      {
           lbNews.Text 
      += "
    •  formats.NewsUrl((DateTime)dt.Rows[counter]["NewsPubTime"],Convert.ToInt32(dt.Rows[counter]["NewsID"])) + "" target="_blank">" + dt.Rows[counter]["NewsTitle"].ToString() + "";
           counter
      ++;
          }

         }

         
      else
         
      {
          lbNews.Text
      ="暂无内容";
         }

         lbNews.Text 
      += "
    ";
       dt.Clear();
       dt.Dispose();
       
      }

    UrlFormat.cs

    public class UrlFormat
     
    {

      
    public UrlFormat()
      
    {
      }


      
    public virtual string NewsUrl(DateTime dt,int NewsID)
      
    {
          
    return GetUrl("News,{0},{1},{2}," + NewsID + ".aspx",dt.Year,dt.Month,dt.Day);
      }


      
    protected virtual string GetUrl(string pattern, params object[] items)
      
    {
       
    return string.Format(pattern,items);
      }


     }



    格式化为:
    news,2004,8,13,123.aspx

    指向:
    news.aspx?参数=some parameter

    噢耶游戏是中国最大的轻社交游戏开发商,致力于手机页游的研发及推广业务。我们首创性地提出了HTML5游戏中心思路,在第三方App 中嵌入式休闲游戏,为开发者提供了全新的应用内游戏解决方案。
  • 相关阅读:
    IDEA 2019.3 最新激活教程,有效期到 2089 年!
    【猫狗数据集】读取数据集的第二种方式
    【猫狗数据集】计算数据集的平均值和方差
    【colab pytorch】其它注意事项
    【colab pytorch】训练和测试常用模板代码
    【colab pytorch】数据预处理
    【colab pytorch】提取模型中的某一层
    【colab pytorch】模型权重初始化
    【猫狗数据集】使用预训练的resnet18模型
    【猫狗数据集】使用top1和top5准确率衡量模型
  • 原文地址:https://www.cnblogs.com/yintian2/p/854981.html
Copyright © 2011-2022 走看看