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 911249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:10:25+00:00 2026-05-15T17:10:25+00:00

I have created a utility method that contains some try/catches in it. In those

  • 0

I have created a utility method that contains some try/catches in it. In those try/catches I need to redirect the customer using an HttpResponse redirect. I can’t seem to figure out how to do this outside a web project. This utility class is referenced from my ASP.NET web project and so I’m just abstracting out some of the code into this utility class so I no longer have the request object.

I know I can use HttpWebRequest object for a lot of web related request tasks outside a web project, but could not seem to get any redirect method there to use after putting in a using System.Net; in my utility class.

  • 1 1 Answer
  • 1 View
  • 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-15T17:10:25+00:00Added an answer on May 15, 2026 at 5:10 pm

    Top of your file:

    using System.Web;
    

    In your function:

    HttpContext.Current.Response.Redirect("http://www.mysite.com/redirect");
    

    This way does make your library dependant on the System.Web library, but your code isn’t in a web project. It will grab the current HttpContext for the request it’s called from. You’ll probably want to do some null checking though, if this code is called from outside of a web-context you’re going to get a NullReferenceException.

    If you’re using WCF there’s a different context-object you want to use, I just can’t remember what it is. OperationContext maybe?

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

Sidebar

Related Questions

I have a smallish utility library I made that I had created in TFS
I have created some JQuery that will expand a div 'popup' on hover and
I have a utility method (= a static one) that I call a lot,
I have a simple regex conversion method that I use to do some minor
I've created a small utility function for string conversion so that I don't have
I often have the need to search a javascript array that contains objects. I
I have created an utility function which I include in almost all Javascript code
Ok, I have created a little utility with AppleScript and used Automator to turn
I have a need to create a utility in Suze Linux. The utility will
I have a utility class that creates & returns a db connection: Public Shared

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.