Bug 566 - DateTimeOffset? as a parameter in mvc3 throws System.ArgumentNullException
Summary: DateTimeOffset? as a parameter in mvc3 throws System.ArgumentNullException
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: 2.10.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-08-31 09:13 UTC by jeroen
Modified: 2011-10-28 06:46 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Monodevelop test project (645.78 KB, application/zip)
2011-08-31 09:14 UTC, jeroen
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 566 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description jeroen 2011-08-31 09:13:40 UTC
The following code throws a ArgumentNullException when using the System.Web.Mvc from mvc3:

using System;
using System.Web.Mvc;

namespace DateTimeOffsetSet
{
	public class HomeController : Controller
	{
		public ActionResult Index(DateTimeOffset? date)
		{
			return Content(!date.HasValue ? "no date" : date.ToString());
		}
	}
}

This will throw an exception - Incorrect:
http://127.0.0.1:8080/Home/Index
(expected: "no date")

This won't throw - Correct:
http://127.0.0.1:8080/Home/Index?date=
(expected & got: "no date")

This won't throw an exception, but the date value is still null and "no date" is displayed - Incorrect.
http://127.0.0.1:8080/Home/Index?date=2011-08-08
(expected: "8-8-2011 0:00:00 +02:00")

When changing the parameter into "DateTime? date" the code works as expected.


Stacktrace when exception is thrown:
System.ComponentModel.DataAnnotations.ValidationContext..ctor (instance=(null), serviceProvider=(null), items=(null)) in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.ComponentModel.DataAnnotations/System.ComponentModel.DataAnnotations/ValidationContext.cs:48
System.Web.Mvc.DataAnnotationsModelValidator+<Validate>d__1.MoveNext () in 
System.Web.Mvc.ModelValidator+CompositeModelValidator+<Validate>d__5.MoveNext () in 
System.Web.Mvc.DefaultModelBinder.OnModelUpdated (controllerContext={System.Web.Mvc.ControllerContext}, bindingContext={System.Web.Mvc.ModelBindingContext}) in 
System.Web.Mvc.DefaultModelBinder.BindComplexElementalModel (controllerContext={System.Web.Mvc.ControllerContext}, bindingContext={System.Web.Mvc.ModelBindingContext}, model=(null)) in 
System.Web.Mvc.DefaultModelBinder.BindComplexModel (controllerContext={System.Web.Mvc.ControllerContext}, bindingContext={System.Web.Mvc.ModelBindingContext}) in 
System.Web.Mvc.DefaultModelBinder.BindModel (controllerContext={System.Web.Mvc.ControllerContext}, bindingContext={System.Web.Mvc.ModelBindingContext}) in 
System.Web.Mvc.ControllerActionInvoker.GetParameterValue (controllerContext={System.Web.Mvc.ControllerContext}, parameterDescriptor={System.Web.Mvc.ReflectedParameterDescriptor}) in 
System.Web.Mvc.ControllerActionInvoker.GetParameterValues (controllerContext={System.Web.Mvc.ControllerContext}, actionDescriptor={System.Web.Mvc.ReflectedActionDescriptor}) in 
System.Web.Mvc.ControllerActionInvoker.InvokeAction (controllerContext={System.Web.Mvc.ControllerContext}, actionName="Index") in 
System.Web.Mvc.Controller.ExecuteCore () in 
System.Web.Mvc.ControllerBase.Execute (requestContext={System.Web.Routing.RequestContext}) in 
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute (requestContext={System.Web.Routing.RequestContext}) in 
System.Web.Mvc.MvcHandler+<>c__DisplayClass6+<>c__DisplayClassb.<BeginProcessRequest>b__5 () in 
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass1.<MakeVoidDelegate>b__0 () in 
System.Web.Mvc.Async.AsyncResultWrapper+<>c__DisplayClass8`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].<BeginSynchronous>b__7 (_={System.Web.Mvc.Async.SimpleAsyncResult}) in 
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].End () in 
System.Web.Mvc.Async.AsyncResultWrapper.End (asyncResult={System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult<System.Web.Mvc.Async.AsyncVoid>}, tag={object}) in 
System.Web.Mvc.Async.AsyncResultWrapper.End (asyncResult={System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult<System.Web.Mvc.Async.AsyncVoid>}, tag={object}) in 
System.Web.Mvc.MvcHandler+<>c__DisplayClasse.<EndProcessRequest>b__d () in 
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0 (f={System.Action}) in 
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust (action={System.Action}) in 
System.Web.Mvc.MvcHandler.EndProcessRequest (asyncResult={System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult<System.Web.Mvc.Async.AsyncVoid>}) in 
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest (result={System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult<System.Web.Mvc.Async.AsyncVoid>}) in 
System.Web.HttpApplication.async_handler_complete_cb (ar={System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult<System.Web.Mvc.Async.AsyncVoid>}) in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1008
System.Web.Mvc.Async.AsyncResultWrapper+WrappedAsyncResult`1[[System.Web.Mvc.Async.AsyncVoid, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].Begin (callback={System.AsyncCallback}, state={System.Web.Mvc.MvcHandler}, timeout=-1) in 
System.Web.Mvc.Async.AsyncResultWrapper.BeginSynchronous (callback={System.AsyncCallback}, state={System.Web.Mvc.MvcHandler}, func={System.Func<System.Web.Mvc.Async.AsyncVoid>}, tag={object}) in 
System.Web.Mvc.Async.AsyncResultWrapper.BeginSynchronous (callback={System.AsyncCallback}, state={System.Web.Mvc.MvcHandler}, action={System.Action}, tag={object}) in 
System.Web.Mvc.MvcHandler+<>c__DisplayClass6.<BeginProcessRequest>b__2 () in 
System.Web.Mvc.SecurityUtil+<>c__DisplayClassb`1[[System.IAsyncResult, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<ProcessInApplicationTrust>b__a () in 
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0 (f={System.Action}) in 
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust (action={System.Action}) in 
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust (func={System.Func<System.IAsyncResult>}) in 
System.Web.Mvc.MvcHandler.BeginProcessRequest (httpContext={System.Web.HttpContextWrapper}, callback={System.AsyncCallback}, state={System.Web.Mvc.MvcHandler}) in 
System.Web.Mvc.MvcHandler.BeginProcessRequest (httpContext={System.Web.HttpContext}, callback={System.AsyncCallback}, state={System.Web.Mvc.MvcHandler}) in 
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest (context={System.Web.HttpContext}, cb={System.AsyncCallback}, extraData={System.Web.Mvc.MvcHandler}) in 
System.Web.HttpApplication+<Pipeline>c__Iterator6.MoveNext () in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1365
System.Web.HttpApplication.Tick () in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.Web/System.Web/HttpApplication.cs:932
System.Web.HttpApplication.Start (x=(null)) in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1568
System.Web.HttpApplication.System.Web.IHttpHandler.ProcessRequest (context={System.Web.HttpContext}) in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.Web/System.Web/HttpApplication.cs:1645
System.Web.HttpRuntime.Process (req={Mono.WebServer.XSPWorkerRequest}) in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.Web/System.Web/HttpRuntime.cs:540
System.Web.HttpRuntime.RealProcessRequest (o={Mono.WebServer.XSPWorkerRequest}) in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.Web/System.Web/HttpRuntime.cs:466
System.Web.HttpRuntime.ProcessRequest (wr={Mono.WebServer.XSPWorkerRequest}) in /private/tmp/monobuild/build/BUILD/mono-2.10.3/mcs/class/System.Web/System.Web/HttpRuntime.cs:571
Mono.WebServer.MonoWorkerRequest.ProcessRequest () in /private/tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer/MonoWorkerRequest.cs:400
Mono.WebServer.BaseApplicationHost.ProcessRequest (mwr={Mono.WebServer.XSPWorkerRequest}) in /private/tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer/BaseApplicationHost.cs:121
Mono.WebServer.XSPApplicationHost.ProcessRequest (reqId=65536, localEP={127.0.0.1:8080}, remoteEP={127.0.0.1:63129}, verb="GET", path="/", queryString=(null), protocol="HTTP/1.1", inputBuffer={byte[396]}, redirect=(null), socket=0x8, ssl=(null)) in /private/tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer.XSP/XSPApplicationHost.cs:115
Mono.WebServer.XSPWorker.RunInternal (state=(null)) in /private/tmp/monobuild/build/BUILD/xsp-2.10.2/src/Mono.WebServer.XSP/XSPWorker.cs:193
Comment 1 jeroen 2011-08-31 09:14:36 UTC
Created attachment 223 [details]
Monodevelop test project