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 written a utility that search logfiles for exceptions and it have worked
My small utility application asks the user for an output directory via a GUI
I have what I know is a simple question, but after many searches in
Static utility methods are generally frowned up by OO purists. I was wondering however
I have a sharp architecture project and I am making use of ApplicationServices in
For my framework I've written down this concept to solve the form validation problem.
To preface, this is my first attempt at MVVM... I buy it, I'm just
I am receiving INFO: The remote computer disconnected: Protocol error: packet too long: 65580
What naming conventions do you use for everyday code? I'm pondering this because I

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.