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

  • Home
  • SEARCH
  • 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 7551181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:24:53+00:00 2026-05-30T10:24:53+00:00

I have a controller POST action that redirects to a GET method using RedirectToAction.

  • 0

I have a controller POST action that redirects to a GET method using RedirectToAction.

return RedirectToAction(SomeActionName, new {  date = someModel.someUTCDate });

I have implemented a custom model binder which parses dates using the assumed culture and timezone information, so I am intercepting this correctly. The basic steps in my problem:

  1. POST action is called with a date/time string, which is GMT Standard Time if not specified otherwise
  2. The custom model binder parses this date to a DateTime with a Kind of Utc, and this is bound correctly in the correct format to the model
  3. The POST action redirects to GET using RedirectToAction with the date that was bound as UTC time on the model
  4. MVC3 is now trying to bind a DateTime string value with the month and day swapped around

Somewhere between calling RedirectToAction and rebinding the DateTime value for the GET action, a string conversion is taking place, which appears to be swapping the month and the day around.

Is there a simple way of ensuring that the correct string conversion takes place without the overhead of having to manually convert it for each RedirectToAction call? I would really like to know where this route value to string conversion takes place and whether or not I could influence it to do the correct string conversion.

To illustrate what I have a bit better, I have a custom DateTime model binder

public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
    ValueProviderResult value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);

    if (value == null || string.IsNullOrEmpty(value.AttemptedValue) || value.AttemptedValue == "null")
    {
        return null;
    }

    return FormatHelper.ConvertStringFromGMT(value.AttemptedValue);
}

On redirect I am finding that the model binder’s value.AttemptedValue is an incorrectly formatted string.

  • 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-30T10:24:55+00:00Added an answer on May 30, 2026 at 10:24 am

    Well, the issue is now resolved. As far as I can tell, when MVC gets the route values for your redirect, the route values are converted to query string parameters using the invariant culture. This is just some magic that happens behind the scenes. My solution to this problem was to override the controller methods RedirectToAction and RedirectToActionPermanent (the overloads that take a RouteValueDictionary). I iterate over the RouteValueDictionary and convert any date types here using the defined culture and timezone information. Fortunately all of my controllers were already inheriting from a custom base controller so the fix was simple to implement.

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

Sidebar

Related Questions

I have parent view that also renders sub-controller action using RenderAction() (that returns a
I am using ajaxSubmitButton to POST data to my controller. That controller action then
When you call RedirectToAction within a controller, it automatically redirects using an HTTP GET.
I have a POST controller action like: if (ModelState.IsValid) { try { //.. save
I have a controller insert action: <AcceptVerbs(HttpVerbs.Post)> _ Function InsertObject(<Bind(Exclude:=Id)> <ModelBinder(GetType(CustomModelBinder))> ByVal object As
This is working, but how??? I have a controller action for a post: [AcceptVerbs(HttpVerbs.Post
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
I have a controller method with the following signature: [AcceptVerbs(HttpVerbs.Post)] public ActionResult UpdateValues(int id,
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have controller with action new , and I want it to create ActiveRecord::Base

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.