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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:29:30+00:00 2026-05-10T23:29:30+00:00

Is it OK – best practise wise – to use the second layer to

  • 0

Is it OK – best practise wise – to use the second layer to redirect the user?

For example:

public static void ForceLogin() {     HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieName];      if (cookie != null)     {         if (Regex.IsMatch(cookie.Value, '^[0-9]+\\.[a-f0-9]+$'))         {             using (EibxDataContext db = new EibxDataContext())             {                 int count = db.Logins.Count(l => l.Password == cookie.Value);                  if (count == 1)                 {                     return;                 }             }         }     }      HttpContext.Current.Response.Redirect('~/Login.aspx'); } 

At the last line, I use the Business/Service Logic Layer to redirect the user to the login page.

Should this be done in the Presentation layer?

  • 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. 2026-05-10T23:29:31+00:00Added an answer on May 10, 2026 at 11:29 pm

    Absolutely not. The business logic layer should make the decision, the UI layer should do the redirect. The business layer shouldn’t know anything about HttpContext nor should it be directly reading cookies. Pass the relevant information into the business layer so that the business layer can make the decision, and pass the decision out to the UI layer so that it can work on the resultant decision.

    Here’s the reason… what if the business layer is used from a web service? How can the business layer do a redirect in that instance? Or suppose it’s used with a non-web client? Redirection has no meaning in that context. If you change your UI layer, that should not affect your business logic layer, and mixing in redirects and cookie reading into the business layer will necessitate that with the proposed design.

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

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer if you have .NET framework 1.1. only, probably your best… May 11, 2026 at 11:36 pm
  • Editorial Team
    Editorial Team added an answer If I am understanding the problem correctly then in browsers… May 11, 2026 at 11:36 pm
  • Editorial Team
    Editorial Team added an answer Most current IP stacks will not respond to a ping… May 11, 2026 at 11:36 pm

Related Questions

Is it OK if the same OpenSSL context is used by several different accepting
Is it OK - best practise wise - to use the second layer to
Is it ok to do the following: View(new {Object A, Object B}) Or should
Is it OK to use == on enums in Java, or do I need
Is it OK to have a static member variable defined in a base class,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.