Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6906023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:15:21+00:00 2026-05-27T08:15:21+00:00

In my global.asax.vb file, I have code to re-write the URL if there is

  • 0

In my global.asax.vb file, I have code to re-write the URL if there is a prefix on the URL. We are introducing a new context in our application. So every page will either be of context hair or saliva.

Before the ASP.NET code (stack) even reaches this Global code, it calls an application block called UIProcess. It’s code that Microsoft wrote years ago, and is no longer supported. The UIP block sort of mimics MVC, and you store all views, navigation and controller details inside the web.config. The UIP block is doing a redirect as shown below. Note, they had a known bug that was never fixed (commented out), so I had to recompile it before upgrading from .NET 2.0 to .NET 3.5. That’s what I have commented out. That’s the only bug I’m aware of.

    private void RedirectToNextView(string previousView, ViewSettings viewSettings)
    {
        try
        {
            //if (previousView == null)
            //    HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type, true);
            //else
            //    HttpContext.Current.Response.Redirect(HttpContext.Current.Request.ApplicationPath + "/" + viewSettings.Type, false);
            if (previousView == null)
                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) { }
    }

Here is the Global.asax.vb code:
(again this code doesn’t matter right now because it’s not getting here YET with the exception being thrown)

Sub Application_BeginRequest(ByVal sender As Object, _
                             ByVal e As EventArgs)
    ' Fires at the beginning of each request
    Dim originalUri As Uri = Request.Url
    Dim rewrittenUrl As String = String.Empty

    'Rewrite Saliva and Hair Testing urls 
    Select Case True
        Case originalUri.AbsolutePath.StartsWith("/HairTest/")
            rewrittenUrl = originalUri.AbsolutePath.Remove(0, 9)

            If Not originalUri.Query.Contains("SampleTypeContext=247") Then
                rewrittenUrl += "?sampleTypeContext=247"
            End If
        Case originalUri.AbsolutePath.StartsWith("/SalivaTest/")
            rewrittenUrl = originalUri.AbsolutePath.Remove(0, 11)

            If Not originalUri.Query.Contains("SampleTypeContext=3301") Then
                rewrittenUrl += "?sampleTypeContext=3301"
            End If
    End Select

    If rewrittenUrl <> String.Empty Then
        'append the original query if there was one specified
        If originalUri.Query <> String.Empty Then
            If rewrittenUrl.Contains("?") Then
                rewrittenUrl += "&"
            Else
                rewrittenUrl += "?"
            End If
            rewrittenUrl += originalUri.Query.Remove(0, 1)
        End If
        Context.RewritePath(rewrittenUrl)
    End If
End Sub

The application is actually causing an exception above, when I try to pre-pend my URL (viewSettings.Type variable above) with “/HairTest” or “/SalivaTest”. It causes that System.Threading.ThreadAbortException. I’m thinking because that path doesn’t actually exist in our web application, but I’m just guessing. Notice, we’re doing a re-write in our global, not a redirect. Our re-write prepends the URL with “/HairTest” or “/SalivaTest”.

All of the pages in our web application expect that “SampleTypeContext” parameter if it needs it. If you can think of a way that will work better for this situation, let me know. I’ll try to get more details on the exception.

Looking for ideas!! Our architecture approach is still up for discussion if we run into issues with this UIProcess block. We can’t just get rid of the UIP block since it’s used throughout our application, but I can modify the code above (in my first code snippet) if we need to.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:15:22+00:00Added an answer on May 27, 2026 at 8:15 am

    There’s no standard way to do this with the UIP block. And Microsoft doesn’t maintain it anymore. I overloaded a bunch of the methods in the library to make it work. So that we can append a query string parameter (applicationScope) on each of our UIP redirect calls.

    If you need the code, add a comment here, and I’ll send you the source.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in my Global.asax file: Protected Sub Application_PreRequestHandlerExecute(sender As Object,
Right now, in development I have the following code in the Global.asax.cs file that
I created a global.asax file for an asp.net application. I run some code in
I have code in the global.asax file's Application_Error event which executes when an error
In my Global.asax file, I have the following code that deals with with unhandled
I have 2 test and 1 production server. In my global.asax file - I
I have code in global.asax that sets some things in cache with CacheItemRemovedCallback. When
I have the following in my Global.asax.cs routes.MapRoute( Arrival, {partnerID}, new { controller =
In my Global.ASAX file i have the following: void Session_End(object sender, EventArgs e) {
I have this authentication check in my global.asax file in the Session_OnStart() call: if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.