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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:50:29+00:00 2026-05-14T04:50:29+00:00

Just started working with .NET and MVC(1). I’m having a problem wherein in my

  • 0

Just started working with .NET and MVC(1). I’m having a problem wherein in my add action the entered date for some reason ends up as 1/1/0001 instead of what is entered thus causing a date overflow.

In my model, this field (“Added”) is is of type datetime and does not allow nulls.

In my controller I have:

public ActionResult Add()
    {
        Instance instance = new Instance()
        {
            Added = DateTime.Now,
            Active = true
        };

        return View(instance);
    }

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Add(Instance instance)
    {

        if (ModelState.IsValid)
        {
            try
            {
                System.Diagnostics.Trace.Write("test");
                instanceRepository.Add(instance);
                instanceRepository.Save();

                return RedirectToAction("Details", new { id = instance.InstanceID });
            }
            catch
            {
                ModelState.AddRuleViolations(instance.GetRuleViolations());
            }
        }
        return View(instance);
    }

And in my view I have:

        <div class="editor-label">
            <%= Html.LabelFor(model => model.Added) %>
        </div>
        <div class="editor-field">
            <%= Html.TextBoxFor(model => model.Added,String.Format("{0:g}",Model.Added))%>
            <%= Html.ValidationMessageFor(model => model.Added) %>

When I first go to Instances/Add the default value is set correctly, however as soon as I submit the date turns into 1/1/0001 (from my understanding this indicates that it was either null or in an unrecognizable format)

When I debug and palce a watch on Request.Form I see the date coming in encoded ie Request.Form {Added=4%2f9%2f2010+8%3a24%3a39+AM} – is this an issue?

I know its probably not enough information to make a conlusive determination on why this is failing, but if someone could provide some good debugging tips on how to determine where the submitted date is getting munged I’d really appreciate it.

  • 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-14T04:50:30+00:00Added an answer on May 14, 2026 at 4:50 am

    Thanks for all the answers… The mistake turned out to be in my partial model class:

    namespace MSSQL_Manager.Models
    {
    [Bind(Include="xxxxxx,xxxxx,xxxx,xxxx")]
    public partial class Instance
    {
        public bool IsValid
        {
            get { return (GetRuleViolations().Count() == 0); }
        }
    

    I didn’t have the ‘Added’ field in the [Bind(Include=”xxxx”)] attribute.

    Need to read up more on attributes – thanks everyone for their time

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

Sidebar

Related Questions

I've just started working with ASP.NET MVC now that it's in beta. In my
can anyone help? I have just started asp.net mvc and its all working.. entering
I've just started working on an ASP.NET project which I hope to open source
I just started working on an asp.net / C#.net application that is going to
i am just getting started with ASP.NET MVC and i'm using NHibernate for my
I am working with an ASP.NET MVC project which was originally started from the
I am new to ASP and ASP.net. I have just started working on a
I just started working with Yaws to try to create some simple RESTful web
I just started working for a pretty large company and my group manages all
I'm just getting started working with foreign keys for the first time and I'm

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.