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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:41:47+00:00 2026-05-27T01:41:47+00:00

I have a simple MVC3 application that I want to retrieve some configuration details

  • 0

I have a simple MVC3 application that I want to retrieve some configuration details from a service, allow the user to edit and save the configuration.

If any errors are detected during the saving process, these are to be returned and reported back to the user.

The problem is that the configuration containing the errors is failing to be called and the currently saved values are just being redisplayed.

Stepping through the code, when errors are detected, it should redirect to itself using the passed config object but it doesn’t and uses the method with no parameter.

Can anyone see where I’m going wrong?

Below are the two controller methods that are being called:

//
// GET: /Settings/Edit/
    public ActionResult Edit()
{
    SettingsViewModel config = null;

    // Set up a channel factory to use the webHTTPBinding
    using (WebChannelFactory<IChangeService> serviceChannel =
        new WebChannelFactory<IChangeService>(new Uri(baseServiceUrl)))
    {
        // Retrieve the current configuration from the service for editing
        IChangeService channel = serviceChannel.CreateChannel();
        config = channel.GetSysConfig();
    }

    ViewBag.Message = "Service Configuration";

    return View(config);
}

//
// POST: /Settings/Edit/
[HttpPost]
public ActionResult Edit( SettingsViewModel config)
{
    try
    {
        if (ModelState.IsValid)
        {
            // Set up a channel factory to use the webHTTPBinding
            using (WebChannelFactory<IChangeService> serviceChannel = new WebChannelFactory<IChangeService>(new Uri(baseServiceUrl)))
            {
                IChangeService channel = serviceChannel.CreateChannel();
                config = channel.SetSysConfig(config);

                // Check for any errors returned by the service
                if (config.ConfigErrors != null && config.ConfigErrors.Count > 0)
                {
                    // Force the redisplay of the page displaying the errors at the top
                    return RedirectToAction("Edit", config);
                }
            }
        }

        return RedirectToAction("Index", config);
    }
    catch
    {
        return View();
    }
}
  • 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-27T01:41:48+00:00Added an answer on May 27, 2026 at 1:41 am
    return RedirectToAction("Index", config);
    

    You cannot pass complex objects like this when redirecting. You will need to pass query string parameters one by one:

    return RedirectToAction("Index", new {
        Prop1 = config.Prop1,
        Prop2 = config.Prop2,
        ...
    });
    

    Also I couldn’t see an Index action in your controller. Maybe it’s a typo. Another thing I notice is that you have an Edit GET action to which you are probably trying to redirect but this Edit action doesn’t take any parameters so it just seems weird. If you are trying to redirect to the POST Edit action, well, that’s obviously impossible since a redirect is always on GET by its very nature.

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

Sidebar

Related Questions

I have a fairly simple Action in an MVC3 application that should render an
I'm using MVC3 and have a simple helper that draws a box with some
In my MVC 3 C# application I have some static object that I want
I have simple win service, that executes few tasks periodically. How should I pass
I have a simple MVC 3 application. I want the site to automatically redirect
I have an ASP.NET MVC 3 application that binds data to a Model. Simple
Prehistory: I have a simple ASP.NET MVC3 application. In the project file i've turned
I have a vb.net MVC3 application using RAZOR views. Some of the functions take
I have a simple application with MVC pages that have no javascript, images or
I have created a simple MVC3 web site and I want to limit access

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.