Url重写问题????

这些代码是从.Text Blog Engeer中修改过来的
仅备自用的,
using System;
using System.Web ;
using System.Web.SessionState;
using System.Collections.Specialized;
namespace DHZUR
{
 public class DHZUrlHandlerAspx : IHttpHandler
 {
  public void ProcessRequest(HttpContext ctx)
  {
   HttpResponse Response=ctx.Response;
   Response.Write("This is my handler");
  }
  public bool IsReusable
  {
   get { return true; }
  }
 }
}
using System;
using System.Web ;
using System.Web.SessionState;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
using System.Text;
using System.Web.UI ;
namespace DHZUR
{
 public class  DHZUrlHandlerAspxFactory:IHttpHandlerFactory
 {
  public DHZUrlHandlerAspxFactory(){}
  protected virtual HttpHandler[] GetHttpHandlers(HttpContext context)
  {
   return DHZUR.DHZUrlReWriteHandlerConfig.Instance().HttpHandlers;
  }
  /// <summary>
  /// Implementation of IHttpHandlerFactory. By default, it will load an array of HttpHanlder (Dottext.UrlManager.HttpHandler) from
  /// the blog.config. This can be changed, by overrideing the GetHttpHandlers(HttpContext context) method.
  /// </summary>
  /// <param name="context">Current HttpContext</param>
  /// <param name="requestType">Request Type (Passed along to other IHttpHandlerFactory's)</param>
  /// <param name="url">The current requested url. (Passed along to other IHttpHandlerFactory's)</param>
  /// <param name="path">The physical path of the current request. Is not gaurenteed to exist (Passed along to other IHttpHandlerFactory's)</param>
  /// <returns>
  /// Returns an Instance of IHttpHandler either by loading an instance of IHttpHandler or by returning an other
  /// IHttpHandlerFactory.GetHanlder(HttpContext context, string requestType, string url, string path) method
  /// </returns>
  public virtual IHttpHandler GetHandler(HttpContext context, string requestType, string url, string path)
  {
   //Get the Handlers to process. By defualt, we grab them from the blog.config
   //Dottext.Framework.Logger.LogManager.Log("url",context.Request.Path);
   HttpHandler[] items = GetHttpHandlers(context);
   //Dottext.Framework.Logger.LogManager.Log("path",Dottext.Framework.Util.Globals.RemoveAppFromPath(context.Request.Path,context.Request.ApplicationPath));
   //Do we have any?
   string pc=context.Request.FilePath;
   if(items != null)
   {
    int count = items.Length;
    for(int i = 0; i<count; i++)
    {
     //We should use our own cached Regex. This should limit the number of Regex's created
     //and allows us to take advantage of RegexOptons.Compiled
     System.Text.RegularExpressions.Regex regex=new System.Text.RegularExpressions.Regex(items[i].Pattern ,RegexOptions.IgnoreCase|RegexOptions.Compiled);
                    string res=DHZUrlHandlerAspxFactory.RemoveAppFromPath(context.Request.Path,context.Request.ApplicationPath);
     if(regex.IsMatch(res))
     {
      //throw new Exception();
      switch(items[i].HandlerType)
      {
       case HandlerType.Page://默认是Page
              
        return ProccessHandlerTypePage(items[i],context,requestType,url);
       case HandlerType.Factory:
        //HandlerConfiguration.SetControls(context,items[i].BlogControls);
        return (IHttpHandler)items[i].Instance();
       case HandlerType.Direct:
        //Pass a long the request to a custom IHttpHandlerFactory
        return ((IHttpHandlerFactory)items[i].Instance()).GetHandler(context,requestType,url,path);
       default:
        throw new Exception("Invalid HandlerType: Unknown");
      }
     }
    }
   }
   //If we do not find the page, just let ASP.NET take over
   return DHZUrlReWritePageHandlerFactory.GetHandler(context,requestType,url, path);
  }
  public static string RemoveAppFromPath(string path,string app)
  {
   path=Regex.Replace(path,"^"+app,string.Empty,RegexOptions.IgnoreCase);
   if(!path.StartsWith("/"))
   {
    path="/"+path;
   }
   //Dottext.Framework.Logger.LogManager.Log("path",path);
   return path;
      
  }
  private IHttpHandler ProccessHandlerTypePage(HttpHandler item, HttpContext context, string requestType, string url)
  {
   string pagepath = context.Server.MapPath(context.Request.FilePath);
   
    IHttpHandler myhandler=PageParser.GetCompiledPageInstance(url,pagepath,context);
   return myhandler;
  }

  public virtual void ReleaseHandler(IHttpHandler handler)
  {
  }
 }
}
///

using System;
using System.Web ;
using System.Web.SessionState;
using System.Collections.Specialized;
namespace DHZUR
{
 public class DHZUrlHandlerForbidden:IHttpHandler
 {
  #region IHttpHandler 成员
  public void ProcessRequest(HttpContext context)
  {
   // TODO:  添加 DHZUrlHandlerForbidden.ProcessRequest 实现
   //在这之前已经判断了请求的文件是否存在的问题!!!
   context.Response.Write("<B>对不起!禁止访问!!</B><BR>");
   context.Response.End ();
   //throw new HttpException(403,"DHZ  Invalid Path: " + context.Request.Path);
  }
  public bool IsReusable
  {
   get
   {
    // TODO:  添加 DHZUrlHandlerForbidden.IsReusable getter 实现
    return true;
   }
  }
  #endregion
 }
}
using System;
using System.Web ;
using System.Web.SessionState;
using System.Collections.Specialized;
namespace DHZUR
{
 public class  DHZUrlHandlerForbiddenFactory:IHttpHandlerFactory
 {
  public IHttpHandler GetHandler(HttpContext ctx,
   string requestType,
   string url,
   string pathTranslated)
  {
   DHZUrlHandlerForbidden hd=new DHZUrlHandlerForbidden();
   return hd;
  
  
   
  }
  public void ReleaseHandler(IHttpHandler handler)
  {
  }
 }
}
//
using System;
using System.Web;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Reflection;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.XPath;
namespace DHZUR
{
 /// <summary>
 /// Summary description for RedirectHandler.
 /// </summary>
 public class DHZUrlRedirectHandler :IHttpHandler
 {
  public DHZUrlRedirectHandler()
  {
   //
   // TODO: Add constructor logic here
   //
  }
  #region IHttpHandler Members
  public void ProcessRequest(HttpContext context)
  {
   
   string uri = context.Request.Path;
   string redirectUrl = "WebForm1.aspx?ID=dhzTest";
   context.Response.StatusCode = 301;
   context.Response.Redirect(redirectUrl,true);
  
  }
  public bool IsReusable
  {
   get
   {
    // TODO:  Add RedirectHandler.IsReusable getter implementation
    return false;
   }
  }
  #endregion
 }
}
///
using System;
using System.Text.RegularExpressions;
using System.Web;
using System.Reflection;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.XPath;
namespace DHZUR
{
 public class  DHZUrlReWriteHandlerConfig:IConfigurationSectionHandler
 {
  private HttpHandler[] _httpHandlers;
  [XmlArray("HttpHandlers")]
  public HttpHandler[] HttpHandlers
  {
   get {return this._httpHandlers;}
   set {this._httpHandlers = value;}
  }
  public DHZUrlReWriteHandlerConfig()
  {
  }
  public static DHZUrlReWriteHandlerConfig Instance()
  {
   return ((DHZUrlReWriteHandlerConfig)ConfigurationSettings.GetConfig("DHZUrlReWriteHandlerConfig"));
  }
  #region IConfigurationSectionHandler 成员
  public object Create(object parent, object configContext, System.Xml.XmlNode section)
  {
   // TODO:  添加 DHZUrlReWriteRuleConfig.Create 实现
   XmlSerializer ser = new XmlSerializer(typeof(DHZUrlReWriteHandlerConfig));
   // Return the Deserialized object from the Web.config XML
   return ser.Deserialize(new XmlNodeReader(section));
  }
  #endregion
 }
 public enum HandlerType
 {
  Direct,
  Factory,
  Page
 };
 public class HttpHandler
 {
  public HttpHandler()
  {
   //
   // TODO: Add constructor logic here
   //
  }
  private HandlerType _handlerType = HandlerType.Page;
  [XmlAttribute("handlerType")]
  public HandlerType HandlerType
  {
   get {return this._handlerType;}
   set {this._handlerType = value;}
  }
  private string _pattern;
  [XmlAttribute("pattern")]
  public string Pattern
  {
   get {return this._pattern;}
   set {this._pattern = value;}
  }
  private string _type;
  [XmlAttribute("type")]
  public string Type
  {
   get {return this._type;}
   set {this._type = value;}
  }
  private readonly object HandlerLock = new object();
  private ConstructorInfo constructor = null;
  public object Instance()
  {
   if(constructor == null)
   {
    lock(HandlerLock)
    {
     if(constructor == null)
     {
      System.Type t = System.Type.GetType("DHZUR.HttpHandler,WebApplication1");
      constructor = t.GetConstructor(new Type[0]);
     }
    }
   }
   return constructor.Invoke(null);
  }
  
 }
 
}
using System;
using System.Web ;
using System.Web.SessionState;
using System.Collections.Specialized;
namespace DHZUR
{
 public class DHZUrlReWriteModule:System.Web.IHttpModule
 {
  #region IHttpModule 成员
  public void Init(HttpApplication context)
  {
   // TODO:  添加 DHZUrlReWriteModule.Init 实现
   context.BeginRequest +=new EventHandler(context_BeginRequest);
  // context.PreRequestHandlerExecute+=new EventHandler(context_BeginReq);
  }
  public void Dispose()
  {
   // TODO:  添加 DHZUrlReWriteModule.Dispose 实现
  }
  #endregion
//  private void context_BeginReq(object sender,EventArgs e)
//  {
//   HttpContext context=(sender as HttpApplication).Context ;
//   string path=context.Server.MapPath(context.Request.FilePath);
//   if(!System.IO.File.Exists(path))
//   {
//    context.Response.Write("不存在这样的文件!<BR>");
//    context.Response.Flush();
//    context.Response.End ();
//   }
//  }
  private void context_BeginRequest(object sender, EventArgs e)
  {
   
   HttpContext context  = ((HttpApplication)sender).Context;
//   context.RewritePath("~/2005/");
//    string p2=context.Request.FilePath;
//   //string path=context.Request.PhysicalPath;//context.Server.MapPath(context.Request.FilePath);
//   try
//   {
//    string path=context.Request.FilePath;
//    System.IO.StreamWriter sw=System.IO.File.AppendText(context.Request.PhysicalApplicationPath+"//pc.txt") ;
//    sw.WriteLine(path);
//    sw.Flush ();
//    sw.Close ();
//   }
//   catch(System.Exception c)
//   {
//    throw new HttpException(404,"路径不对!!!"+c.Message);
//   }
   try
   {
//    
//
   }
   catch(System.Exception c)
   {
    context.Trace.Write("找不到本目击!!!"+c.Message);
   }
   string path=DHZUR.DHZUrlHandlerAspxFactory.RemoveAppFromPath(context.Request.FilePath,context.Request.ApplicationPath);
   if(!System.IO.File.Exists(path))
   {
    if(!context.Request.FilePath.EndsWith(".aspx"))
    {
                  throw new Exception("不存在这样的文件:"+path);
    }
    else
    {
         context.Response.Write(path+":=========:"+context.Request.PhysicalApplicationPath+"<BR>");
     DHZUR.DHZUrlReWriteRuleConfig  ruleConfig=DHZUR.DHZUrlReWriteRuleConfig.Instance();
     foreach(DHZUR.ReWriteRule rwr in ruleConfig.ReWriteRules)
     {     
      context.Response.Write(rwr.LookFor +"::::"+rwr.SendTo+"<BR>");
      //....context.RewritePath ();
     }
     context.Response.End ();
     }
    
   }
   
  }
 }
}
//
using System;
using System.Web ;
using System.Web.SessionState;
using System.Web.UI ;
using System.Collections.Specialized;
using System.Text.RegularExpressions;
using System.Text;
namespace DHZUR
{
 public class DHZUrlReWritePageHandlerFactory
 {
  public DHZUrlReWritePageHandlerFactory(){}
  public static  IHttpHandler GetHandler(HttpContext context, string requestType, string url, string path)
  {
   if(!path.ToLower().EndsWith(".aspx"))
   {
    path = System.IO.Path.Combine(path,"default.aspx");
   }
   return PageParser.GetCompiledPageInstance(url, path, context);
  }
  public  void ReleaseHandler(IHttpHandler handler)
  {
   
  }
  
 }
}
//
using System;
using System.Text.RegularExpressions;
using System.Web;
using System.Reflection;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.XPath;
namespace DHZUR
{
 public class  DHZUrlReWriteRuleConfig:IConfigurationSectionHandler
 {
  private ReWriteRule[] _reWriteRules;
  [XmlArray("ReWriteRules")]
  public ReWriteRule[] ReWriteRules
  {
   get {return this._reWriteRules;}
   set {this._reWriteRules = value;}
  }
  public DHZUrlReWriteRuleConfig()
  {
  }
  public static DHZUrlReWriteRuleConfig Instance()
  {
   return ((DHZUrlReWriteRuleConfig)ConfigurationSettings.GetConfig("DHZUrlReWriteRuleConfig"));
  }
  #region IConfigurationSectionHandler 成员
  public object Create(object parent, object configContext, System.Xml.XmlNode section)
  {
   // TODO:  添加 DHZUrlReWriteRuleConfig.Create 实现
   XmlSerializer ser = new XmlSerializer(typeof(DHZUrlReWriteRuleConfig));
   // Return the Deserialized object from the Web.config XML
   return ser.Deserialize(new XmlNodeReader(section));
  }
  #endregion
 }
 public class  ReWriteRule
 {
  public ReWriteRule()
  {
   //
   // TODO: Add constructor logic here
   //
  }
  private string _lookFor;
  [XmlAttribute("LookFor")]
  public string LookFor
  {
   get {return this._lookFor;}
   set {this._lookFor = value;}
  }
 
  private string _sendTo;
  [XmlAttribute("SendTo")]
  public string SendTo
  {
   get {return this._sendTo;}
   set {this._sendTo = value;}
  }
//  private string _type;
//  [XmlAttribute("type")]
//  public string Type
//  {
//   get {return this._type;}
//   set {this._type = value;}
//  }
  private readonly object HandlerLock = new object();
  private ConstructorInfo constructor = null;
  public object Instance()
  {
   if(constructor == null)
   {
    lock(HandlerLock)
    {
     if(constructor == null)
     {
      System.Type t = System.Type.GetType("DHZUR.ReWriteRule,WebApplication1");
      constructor = t.GetConstructor(new Type[0]);
     }
    }
   }
   return constructor.Invoke(null);
  }
 }
 
}
///
using System;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Security;
using System.Web;

// namespace DotNetGuy.Utility.Web - Renamed for consistency
namespace DHZUR
{
 /// <summary>
 /// Replacement static file handler class. Overcomes the "24-hour cache" bug
 /// in ASP.NET's default static file handler implementation.
 /// </summary>
 public class DHZUrlStaticFileHandler : IHttpHandler
 {
  // Static constructor
  /// <summary>
  /// Static constructor that fills the string dictionary with
  /// the known MIME types.
  /// </summary>
  static DHZUrlStaticFileHandler()
  {
   _mimeMap = new StringDictionary();
   _mimeMap.Add("csv",  "application/vnd.ms-excel");
   _mimeMap.Add("css", "text/css");
   _mimeMap.Add("js", "text/javascript");
   _mimeMap.Add("doc",  "application/msword");
   _mimeMap.Add("gif",  "image/gif");
   _mimeMap.Add("htm",  "text/html");
   _mimeMap.Add("html", "text/html");
   _mimeMap.Add("jpeg", "image/jpeg");
   _mimeMap.Add("jpg",  "image/jpeg");
   _mimeMap.Add("pdf",  "application/pdf");
   _mimeMap.Add("png",  "image/png");
   _mimeMap.Add("ppt",  "application/vnd.ms-powerpoint");
   _mimeMap.Add("rtf",  "application/msword");
   _mimeMap.Add("txt",  "text/plain");
   _mimeMap.Add("xls",  "application/vnd.ms-excel");
   _mimeMap.Add("xml",  "text/xml");
  }
  // IHttpHandler implementation
  /// <summary>
  /// (IHttpHandler.IsReusable)
  /// </summary>
  bool IHttpHandler.IsReusable
  {
   get
   {
    return true;
   }
  }
  /// <summary>
  /// (IHttpHandler.ProcessRequest)
  /// </summary>
  /// <param name="ctxt">HTTP context for the request</param>
  void IHttpHandler.ProcessRequest(HttpContext ctxt)
  {
   string filename = ctxt.Request.PhysicalPath;
   FileInfo fi = _GetFileInfo(filename);
   if (!_FileIsOkayToServe(fi, filename))
    throw new HttpException(404, "Resource not found");
   if (_CachedVersionIsOkay(fi.LastWriteTime.ToUniversalTime(), ctxt.Request))
   {
    ctxt.Response.StatusCode = 304;
    ctxt.Response.SuppressContent = true;
    return;
   }
   ctxt.Response.ContentType = _GetMimeMapping(filename);
   ctxt.Response.AppendHeader("Content-Length", fi.Length.ToString());
   ctxt.Response.Cache.SetLastModified(fi.LastWriteTime);
   ctxt.Response.Cache.SetCacheability(HttpCacheability.Public);
   // TODO: we send the file in one big chunk; if the file is potentially
   // large, this code should be re-written to chunk the transfer in
   // decent sized pieces (say, 64k at a time)
   ctxt.Response.Write("<script language='javascript'>alert('in static file Mapping!!');</script>");
   //ctxt.Response.WriteFile(filename);
  }
  // Private methods
  private bool _CachedVersionIsOkay(DateTime lastWriteTime, HttpRequest Request)
  {
   string ifModified = Request.Headers["If-Modified-Since"];
   if (ifModified != null)
   {
    string lastModified = lastWriteTime.ToString("r");
    return (ifModified == lastModified);
   }
   return false;
  }
  /// <summary>
  /// Verifies that the file is okay to serve.
  /// </summary>
  /// <param name="fi">Information about the file</param>
  /// <param name="filename">The filename</param>
  /// <returns>Returns true if the file is okay; false otherwise</returns>
  private bool _FileIsOkayToServe(FileInfo fi, string filename)
  {
   // Don't serve hidden files or directories
   if ((fi.Attributes & FileAttributes.Hidden) != 0)
    return false;
   if ((fi.Attributes & FileAttributes.Directory) != 0)
    return false;
   // We specifically exclude filenames that end in periods because the
   // ASP.NET static file handler does, but I'm not sure why (there's
   // probably some security reason for it...)
   if (filename[filename.Length - 1] == '.')
    return false;
   return true;
  }
  /// <summary>
  /// Returns a populated FileInfo structure for a file, throwing HTTP exceptions
  /// in response to missing files or security problems.
  /// </summary>
  /// <param name="filename">The filename</param>
  /// <returns>A populated FileInfo structure</returns>
  private FileInfo _GetFileInfo(string filename)
  {
   if (!File.Exists(filename))
    throw new HttpException(404, "Resource not found");
   try
   {
    return new FileInfo(filename);
   }
   catch (IOException)
   {
    throw new HttpException(404, "Resource not found");
   }
   catch (SecurityException)
   {
    throw new HttpException(401, "Access denied");
   }
  }
  /// <summary>
  /// Gets the MIME type for the given filename
  /// </summary>
  /// <param name="filename">The filename</param>
  /// <returns>Returns the mime type for the file; if unknown, return
  /// application/octet-stream (default binary data format in MIME)</returns>
  private static string _GetMimeMapping(string filename)
  {
   string result = null;
   int idx = filename.LastIndexOf('.');
   if (idx > 0 && idx > filename.LastIndexOf('//'))
    result = _mimeMap[filename.Substring(idx+1).ToLower(CultureInfo.InvariantCulture)];
  
   if (result == null)
    return "application/octet-stream";
   else
    return result;
  }
  // Local data
  private static StringDictionary _mimeMap;
 }
}
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <configSections>
  <section name="DHZUrlReWriteRuleConfig" type="DHZUR.DHZUrlReWriteRuleConfig,WebApplication1" />
  
  
  <section name="DHZUrlReWriteHandlerConfig" type="DHZUR.DHZUrlReWriteHandlerConfig,WebApplication1"/>
  
 </configSections>
 <DHZUrlReWriteRuleConfig type="DHZUR.DHZUrlReWriteRuleConfig,WebApplication1">
  <ReWriteRules>
   <ReWriteRule LookFor="^//d{4}//d{2}//d{2}/index.aspx$" SendTo="WebForm1.aspx?year=$1&amp;month=$2&amp;day=$3"></ReWriteRule>
   <ReWriteRule LookFor="^//d{4}/$" SendTo="WebForm1.aspx?year=$1"></ReWriteRule>
   <ReWriteRule LookFor="^//d{4}/.aspx$" SendTo="WebForm1.aspx?ID=$1"></ReWriteRule>
  </ReWriteRules>
 </DHZUrlReWriteRuleConfig>
 <DHZUrlReWriteHandlerConfig type="DHZUR.DHZUrlReWriteHandlerConfig,WebApplication1">
     <HttpHandlers>
       <HttpHandler pattern = "^//d{4}/index.aspx$" type = "DHZUR.DHZUrlRedirectHandler,WebApplication1" handlerType="Direct"/>
     </HttpHandlers>
 </DHZUrlReWriteHandlerConfig>
  <system.web>
  <!--旧的处理方法
 <httpHandlers>
     <add verb="*" path="*.config" type="DHZUR.DHZUrlHandlerForbiddenFactory,WebApplication1"></add>
   <add verb="*" path="*.ascx" type="DHZUR.DHZUrlHandlerForbiddenFactory,WebApplication1"></add>
   <add verb="*" path="*.cs" type="DHZUR.DHZUrlHandlerForbiddenFactory,WebApplication1"></add>
   <add verb="*" path="*.vb" type="DHZUR.DHZUrlHandlerForbiddenFactory,WebApplication1"></add>
   <add verb="*" path="*.vbproj" type="DHZUR.DHZUrlHandlerForbiddenFactory,WebApplication1"></add>
   <add verb="*" path="*.resx" type="DHZUR.DHZUrlHandlerForbiddenFactory,WebApplication1"></add>
   <add verb="*" path="*.resources" type="DHZUR.DHZUrlHandlerForbiddenFactory,WebApplication1"></add>
   <add verb="*" path="*.aspx" type="DHZUR.DHZUrlHandlerAspxFactory,WebApplication1"></add>
 </httpHandlers>
 -->
 <httpHandlers>
  <!--This will process any ext mapped to aspnet_isapi.dll -->
  <add verb="*" path="*" type="DHZUR.DHZUrlHandlerAspxFactory,WebApplication1" />
 </httpHandlers>
 <httpModules>
  <add name="UrReWriteModule" type="DHZUR.DHZUrlReWriteModule,WebApplication1" />
 </httpModules>
    <!--  动态调试编译
          设置 compilation debug="true" 以启用 ASPX 调试。否则,将此值设置为
          false 将提高此应用程序的运行时性能。
          设置 compilation debug="true" 以将调试符号(.pdb 信息)
          插入到编译页中。因为这将创建执行起来
          较慢的大文件,所以应该只在调试时将此值设置为 true,而在所有其他时候都设置为
          false。有关更多信息,请参考有关
          调试 ASP.NET 文件的文档。
    -->
    <compilation
         defaultLanguage="c#"
         debug="true"
    />
    <!--  自定义错误信息
          设置 customErrors mode="On" 或 "RemoteOnly" 以启用自定义错误信息,或设置为 "Off" 以禁用自定义错误信息。
          为每个要处理的错误添加 <error> 标记。
          "On" 始终显示自定义(友好的)信息。
          "Off" 始终显示详细的 ASP.NET 错误信息。
          "RemoteOnly" 只对不在本地 Web 服务器上运行的
           用户显示自定义(友好的)信息。出于安全目的,建议使用此设置,以便
           不向远程客户端显示应用程序的详细信息。
    -->
    <customErrors
    mode="RemoteOnly"
    />
    <!--  身份验证
          此节设置应用程序的身份验证策略。可能的模式是 "Windows"、
          "Forms"、 "Passport" 和 "None"
          "None" 不执行身份验证。
          "Windows" IIS 根据应用程序的设置执行身份验证
            (基本、简要或集成 Windows)。在 IIS 中必须禁用匿名访问。
          "Forms" 您为用户提供一个输入凭据的自定义窗体(Web 页),然后
           在您的应用程序中验证他们的身份。用户凭据标记存储在 Cookie 中。
          "Passport" 身份验证是通过 Microsoft 的集中身份验证服务执行的,
           它为成员站点提供单独登录和核心配置文件服务。
    -->
    <authentication mode="Windows" />
 <!--  授权
           此节设置应用程序的授权策略。可以允许或拒绝不同的用户或角色访问
          应用程序资源。通配符: "*" 表示任何人,"?" 表示匿名
          (未经身份验证的)用户。
    -->
    <authorization>
        <allow users="*" /> <!-- 允许所有用户 -->
            <!--  <allow     users="[逗号分隔的用户列表]"
                             roles="[逗号分隔的角色列表]"/>
                  <deny      users="[逗号分隔的用户列表]"
                             roles="[逗号分隔的角色列表]"/>
            -->
    </authorization>
    <!--  应用程序级别跟踪记录
          应用程序级别跟踪为应用程序中的每一页启用跟踪日志输出。
          设置 trace enabled="true" 可以启用应用程序跟踪记录。如果 pageOutput="true",则
          在每一页的底部显示跟踪信息。否则,可以通过浏览 Web 应用程序
           根目录中的 "trace.axd" 页来查看
          应用程序跟踪日志。
    -->
    <trace
        enabled="false"
        requestLimit="10"
        pageOutput="false"
        traceMode="SortByTime"
  localOnly="true"
    />
    <!--  会话状态设置
          默认情况下,ASP.NET 使用 Cookie 来标识哪些请求属于特定的会话。
          如果 Cookie 不可用,则可以通过将会话标识符添加到 URL 来跟踪会话。
         若要禁用 Cookie,请设置 sessionState cookieless="true"。
    -->
    <sessionState
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false"
            timeout="20"
    />
    <!--  全球化
          此节设置应用程序的全球化设置。
    -->
    <globalization
            requestEncoding="utf-8"
            responseEncoding="utf-8"
   />
  
 </system.web>
</configuration>
//
http://localhost/WebApplication1/WebForm1.aspx:
/WebForm1.aspx:=========:E:/WebSite/WebApplication1/
^//d{4}//d{2}//d{2}/index.aspx$::::WebForm1.aspx?year=$1&month=$2&day=$3
^//d{4}/$::::WebForm1.aspx?year=$1
^//d{4}/.aspx$::::WebForm1.aspx?ID=$1
------是WebForm1.aspx的执行结果
http://localhost/WebApplication1/2006/:时,出错:http:404
看来是没有先截获到这个请求,问题是在哪里可以拦截到呢?????????
郁闷中..........
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值