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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:31:37+00:00 2026-06-10T07:31:37+00:00

I have a controller like this: public FooController : Controller { public ActionResult Index()

  • 0

I have a controller like this:

public FooController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
}

With the Index view:

@{ Html.RenderPartial("~/Views/Bar/Add", new Models.Bar()); }

The Bar controller is like this:

public BarController : Controller
{
    public ActionResult Add()
    {
        var bar = new Bar();
        return View(bar);
    }

    [HttpPost]
    public ActionResult Add(Bar bar)
    {
        if(ModelState.IsValid)
        {
            _repository.AddBar(bar);
            return RedirectToAction("Index", "Foo");
        }

        // This will return only the partial view (No Layout, no outer view)
        return View("Add", bar);

        // This will not show validation errors
        // return RedirectToAction("Index", "Foo");
    }
}

And the Add View looks like this:

@model Models.Bar

@using(Html.BeginForm("Add", "Bar", FormMethod.Post))
{
    Name: @Html.TextBoxFor(x => x.Name)

    <input type="submit" value="Add Bar" />

    @Html.ValidationSummary()
}

My problem is that if I return View("Add", bar) I get the partial view, and nothing else (not what I want). But if I instead return RedirectToAction("Index", "Foo") whether it passes validation or not, I of course lose any validation errors for the valiation summary.

Is there a way to use validation in a partial view like this?

  • 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-06-10T07:31:39+00:00Added an answer on June 10, 2026 at 7:31 am

    You could:

    1. return View("~/Views/Home/Index.cshtml") if validation fails.
    2. Save ModelState on TempData and restore it on the Home.Index action.
    3. Make an AJAX request.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller action like this: public ActionResult Index(string url) { var pageTitle
New to mvc, I have a controller like this public ActionResult Index(DateTime Date, DateTime
I have an MVC controller method defined like this: public ActionResult GetPdf(string filename) {
I have a controller method in ASP.NET MVC that looks like this: public ActionResult
I have a controller that looks like this: public ActionResult Sold() { using (WipDBEntities
I have a controller that looks like this: public class PageController : Controller {
I have a Controller with syntax like this: public class CrudController<TEntity> : Controller Now
I have 2 functions/methods in the same controller in CodeIgniter like this: public function
I have a simple Controller that looks like this:- @Controller @RequestMapping(value = /groups) public
I have a controller something like this: Ext.define('DigitalPaper.controller.Documents', { extend: 'Ext.app.Controller', views: ['Documents'], stores:

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.