Asp.net Mvc: nullable filter parameter

I am trying to use the nullable datetime and double value as a parameter for an actionfilter, but it gives the following error:

'Propertyname' is not a valid attribute name argument because it is not a valid attribute parameter type

I thought a quick google would solve it, but to my surprise I could not find much information about this.

Here is the code for my filter.

public class AddToSitemap : ActionFilterAttribute
{
    public string Changefreq { get; set; }
    public DateTime? Lastmod { get; set; }
    public double? Priority { get; set; }
}

Thanks in advance.

+3
source share
2 answers

Here is the compiler error on MSDN .

You can use only the following types according to the Attribute Tutorial :

:

- Simple types (bool, byte, char, short, int, long, float, and double)
- string
- System.Type
- enums
- object (The argument to an attribute parameter of type object must be a constant value of one of the above types.)
* One-dimensional arrays of any of the above types

, :

  • .
  • Nullable DateTime.
  • DateTime.

int Priority, beeing Double.

DateTime, long Ticks .
, # ( DateTime (1234,5,6). ).

+2

, DateTime ViewModel ..

0

Source: https://habr.com/ru/post/1716529/


All Articles