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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:47:25+00:00 2026-05-16T11:47:25+00:00

I have some doubts regarding the following controller action (in ASP.NET MVC, but it’s

  • 0

I have some doubts regarding the following controller action (in ASP.NET MVC, but it’s a more generic question ) :

public ActionResult DoSomething( int id, IUser currentUser )
{
     var myDomainObject = businessService.GetDomainObjectById( id );

     if( !securityService.CurrentUserCanAcess( currentUser, myDomainObject ) )
     {
         throw new HttpException(403, "forbidden");
     }

     if( workflowService.IsWorkflowFinishedFor( myDomainObject ) )
     {
         return RedirectToAction( "OtherAction", identifier );
     }

     var myModel = entityToModelMapper.GetModel( myDomainObject );

     return View( myModel );
}

workflowService, securityService, businessService and entityToModelMapper are all injected into my controller with IoC.

I’m concerned about having security, business and workflow involved in the same controller action. Is it OK ?

  • 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-16T11:47:25+00:00Added an answer on May 16, 2026 at 11:47 am

    If this is the processing you need then there’s no alternative, they happen as part of the action.

    The question might be whether some refactoring is appropriate. For example, whose responsibility should it it be to check the user’s access rights? Here the action class makes the check and the myDomain object seems to allow anybody to read its contents.

    Similarly the check for the workflow being finished: if the code of the action forgets to make that check, what happens?

    My feeling is that in the current design, when extended to many action methods, this

    Coders, please rember to check access
    permissions and workflow state

    kind of logic could well be reproduced in many action methods – this is a bad thing, we have duplication of code.

    Hence I think some refactoring to push that into the domain object, or a suitable wrapper is appropriate.

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

Sidebar

Related Questions

I have seen this question, and have some more doubts regarding creating a jar
I have the following code: http://jsfiddle.net/fCWJ5/1/ , and following doubts regarding the viewbox. body{margin:0;}
I have programmed an emulator, but I have some doubts about how to organizate
I have some doubts regarding In-Application-Billing in android: Can i test it with different
I have some doubts regarding sitemap.xml generation and Django's sitemap framework particularly. Let's say
I have a couple of questions and doubts to regarding PowerShell and .NET Classes.
I have some doubts regarding service hosting in WCF. I want to host a
i'm writing my first plugin for wordpress and i have some doubts regarding the
i am reading some things about VML, but i have some doubts. What versions
I have some doubts regarding Strings Are they live on Heap or String pool?

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.