System.Web.HttpContext.RewritePath C# (CSharp) Method

RewritePath() public method

public RewritePath ( string path ) : void
path string
return void
		public void RewritePath (string path)
		{
			RewritePath (path, true);
		}

Same methods

HttpContext::RewritePath ( string path, bool rebaseClientPath ) : void
HttpContext::RewritePath ( string filePath, string pathInfo, string queryString ) : void
HttpContext::RewritePath ( string filePath, string pathInfo, string queryString, bool setClientFilePath ) : void

Usage Example

示例#1
0
        /// <summary>
        /// Handles the current request.
        /// </summary>
        /// <param name="context">The current context</param>
        /// <param name="draft">Weather to view the draft</param>
        /// <param name="args">Optional url arguments passed to the handler</param>
        protected virtual void HandleRequest(HttpContext context, bool draft, params string[] args)
        {
            if (args != null && args.Length > 0) {
                Permalink perm = Permalink.GetByName(args[0]) ;

                if (perm != null) {
                    if (perm.Type == Permalink.PermalinkType.PAGE) {
                        Page page = Page.GetSingle(perm.ParentId, draft) ;

                        if (!String.IsNullOrEmpty(page.Controller)) {
                            context.RewritePath("~/templates/" + page.Controller + "/" + perm.Name +
                                (draft ? "?draft=true" : ""), false) ;
                        } else {
                            context.RewritePath("~/page/" + perm.Name + (draft ? "?draft=true" : "")) ;
                        }
                    } else {
                        context.RewritePath("~/post/" + perm.Name + (draft ? "?draft=true" : "")) ;
                    }
                }
            } else {
                //
                // Rewrite to current startpage
                //
                Page page = Page.GetStartpage() ;

                if (!String.IsNullOrEmpty(page.Controller))
                    context.RewritePath("~/templates/" + page.Controller, false) ;
                else context.RewritePath("~/page") ;
            }
        }
All Usage Examples Of System.Web.HttpContext::RewritePath