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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:03:27+00:00 2026-05-23T18:03:27+00:00

I am finding the asp.net mvc framework is leading me towards a fair bit

  • 0

I am finding the asp.net mvc framework is leading me towards a fair bit of duplication. Maybe I just don’t know of the correct way to do things, so I will list some of the areas and maybe someone can suggest the correct approach:

Controller methods that do not accept generic parameters. I have multiple classes, such as:

class A
class B : A
class C : A
class D : A

and controller methods:

EditB(B obj)
EditC(C obj)
EditD(D obj)

All controllers do exactly the same thing, but I am assuming that 1. I can’t have a generic controller parameter, and 2. the model binder will only bind to class A if I do:

EditA(A obj)

The next problem I have is with partials. To get model binding to work easily, I use methods such as:

Html.TextboxFor(m => m.blah.blahID)

but when a partial is shared between multiple views that only have m.blah in common, I do:

RenderPartial("BlahPartial", m.blah);

The problem is that now I would assume that using

Html.TextboxFor(m => m.blahID) 

inside the partial will not give me what I want as it is missing the blah.

Finally, in controller methods, I find it difficult to extract common algorithms into invidiual methods as:

if (a)

return ActionResult("Blah");

else 

return ActionResult("Home");

(or RedirectToAction or return View("Home") etc.)

seem diffuclt to put in private methods as I cannot return those things in anything other then the original controller.

  • 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-23T18:03:27+00:00Added an answer on May 23, 2026 at 6:03 pm

    I’m not sure exactly if I can put you on the right track as your question is pretty generic, but I think that you’ll likely have to have separate controller actions per model. That doesn’t mean that you can’t share code. One way to do that would be to have a common base controller from which each specific controller derives. The code common to all controllers/models can be refactored back to the base controller.

    As far as partials go, you can provide the prefix via ViewData — see http://davybrion.com/blog/2011/01/prefixing-input-elements-of-partial-views-with-asp-net-mvc/

    I’m not sure why you think that you can’t easily have private methods. It’s not difficult to have a private method that returns a particular model or uses a particular view by name.

    private ActionResult RedirectOnSuccess<T>( T model, string action ) where T : IBaseModel
    {
        if (model.IsValid())
        {
            // save to database, etc.
            return RedirectToAction( action );
        }
        return View( model ); // will re-render the view corresponding to the called action
    }
    

    Then call it as

    public ActionResult Edit( SpecificModel model )
    {
       return RedirectOnSuccess( model, "index" );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today is my first day using ASP.NET MVC, and I'm finding it very intriguing.
I'm finding it hard to find out helpful information about ASP.NET MVC's validation HTML
i am finding more and more my asp.net mvc views are starting to look
I am increasingly finding situations where my ASP.NET MVC view requires some logic to
Are there any open-source examples of ASP.NET MVC applications that use the Entity Framework?
While developing an ASP.NET MVC app, I'm finding a few places where my JsonResult
When I do a 'Publish' on my ASP.NET MVC website, I'm finding unnecessary empty
I am new to ASP.NET MVC and am finding the options for displaying something
I'm an everyday C#/ASP.NET MVC/Visual Studio user and i've just started a project in
I'm using the Telerik Extensions for ASP.NET MVC in an MVC3 project. I'm finding

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.