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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:33:01+00:00 2026-05-18T09:33:01+00:00

Using MVCContrib you can easily do RedirectToAction calls such as this.RedirectToAction( c => c.List()

  • 0

Using MVCContrib you can easily do RedirectToAction calls such as

this.RedirectToAction( c => c.List() );

where List is an action result in said controller. Is there a way to do the same but using the “View” method instead? I.E

this.View( c => c.List(), viewModel );

Here’s a trivial but complete example:

[HttpGet]
public ActionResult Profile()
{
    return View( new ProfileViewModel() )
}

[HttpPost]
public ActionResult Profile( ProfilePostModel postModel )
{
    if( !ModelState.IsValid )
        return this.View( c => c.Profile(), postModel.MapToViewModel() );
    _service.Save(postModel.MapToDtoObject() );
    return this.RedirectToAction( c => c.SomeOtherAction() );
}

I’ve been searching around and haven’t found anything relevant.. Thanks!

  • 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-18T09:33:02+00:00Added an answer on May 18, 2026 at 9:33 am

    I don’t know if such method exists in MVCContrib but it would be trivial to write one:

    public static class ControllerExtensions
    {
        public static ViewResult View<T>(
            this T controller, 
            Expression<Func<T, ActionResult>> expression, 
            object model
        ) where T : Controller
        {
            var mce = expression.Body as MethodCallExpression;
            if (mce == null)
            {
                throw new NotSupportedException();
            }
            var result = new ViewResult();
            result.ViewName = mce.Method.Name;
            result.ViewData.Model = model;
            return result;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the MVCContrib Grid. My controller action accepts 3 parameters, the sortoptions and
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I have a simple controller test using MvcContrib's test helpers: var controller = new
I asked this question yesterday, wondering how to produce XML with attributes using MVCContrib.
Using MVC 3 RTM and MvcContrib/FluentHtml version 3.0.51.0, I can't get the jQuery client
I am using mvccontrib grid in asp.net mvc(C#) application. How can i apply css
Is there a way to use something like this: System.Web.Mvc.ViewUserControl<DateTime> ? I get an
I am using MvcContrib and the TestControllerBuilder to write tests for my controller. I
Okay so I am using MVCContrib TestHelper to unit test my controllers, which works
I'm building a plugin framework using MvcContrib's portable areas and MEF to allow adding

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.