As I posted earlier we had some trouble with upgrading the UIPAB to be used in a ASP.Net 2.0 Web Application Project. Eventually, we solved the problem and life was good. Almost a week ago I received a mail through my blog from someone looking for the solution. So here we go…

We changed a few lines in the UIPAB WebFormViewManager. The problem was in determining the application path in the method ‘RedirectToNextView’. Here the applicationpath was all garbled up, which caused the redirect not to work. We implemented a property to return the right applicationpath:






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
       private string applicationPath = null;
 
        /// <summary>
/// Property returning the entire URL to the current request,
/// excluding the page name but including the last slash (“/”)
/// </summary>
private string ApplicationPath
{
get
{
if (applicationPath == null)
{
if (HttpContext.Current.Request.UrlReferrer == null)
{
applicationPath = HttpContext.Current.Request.Url.ToString().Substring(0, HttpContext.Current.Request.Url.ToString().LastIndexOf(“/”) + 1);
applicationPath += “(S(“ + HttpContext.Current.Session.SessionID + “))/”;
}
else
{
applicationPath = HttpContext.Current.Request.UrlReferrer.AbsoluteUri;
applicationPath = applicationPath.Substring(0, applicationPath.LastIndexOf(“)/”) + 2);
}
}
return applicationPath;
}
}

The above returns the path we need. It’s not a perfect example of defensive programming, but that’s not the intention of this post ;).  We added the sessionstring because the application in which we used the UIPAB kept the session id in the URL. The RedirectToNextView method now looks like this:






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    private void RedirectToNextView(string previousView, ViewSettings viewSettings)
    {
try
{
if (previousView == null)
{
HttpContext.Current.Response.Redirect(ApplicationPath + viewSettings.Type, true);
}
else
{
HttpContext.Current.Response.Redirect(ApplicationPath + viewSettings.Type, false);
}
}
catch (System.Threading.ThreadAbortException)
{
}
    }

And that’s it! Looking back the problem seemed so big, but the solution seems/is so simple… ;)