CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: C#

Fix WebFormViewManager problem with Request.ApplicationPath (UIP Block)

347 Views
Copy Code Show/Hide Line Numbers
private void RedirectToNextView(string previousView, ViewSettings viewSettings)
        {
            try
            {
                if( previousView == null )
                    // Fix HttpContext.Current.Request.ApplicationPath because doesn't work well whe application is in root directory
                    // when application is under root ApplicationPath returns "/"
                    // when application is under sub foder ApplicationPath returns "/sub folder"
                    // so remove end "/"
                    // see  http://weblogs.asp.net/dneimke/archive/2004/05/17/133116.aspx
                    //      http://www.cptloadtest.com/2006/07/26/RequestApplicationPath-Is-Evil.aspx
                    HttpContext.Current.Response.Redirect( HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/" + viewSettings.Type, true );
                else
                    HttpContext.Current.Response.Redirect( HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/" + viewSettings.Type , false );
            }
            catch(System.Threading.ThreadAbortException) {}
        }
by Fernando Claverino
  August 08, 2009 @ 7:01pm
Tags:
Description:
When web application is under root UIP block doesn't resolve view location well. This little change on Microsoft.ApplicationBlocks.UIProcess.WebFormViewManager.RedirectToNextView method fixes the problem.

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate