You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.
FromHeaderAttribute (from looking at the code and spending several hours debugging) seems to only support either "string" or "compatible collections" for header binding. However, sometimes the header value is just a simple int or some other similar value (in my case it was a timeout).
While I'm fine with the fact that FromHeaderAttribute doesn't support int (in my case I wanted Nullable), it would be way nicer if it somehow told you this. I don't see any sort of logging and I'm not sure what the best way to "warn" about this problem is, so I guess I'm opening up for discussion.
Personally I would have liked an exception to be thrown for an unsupported type of parameter.
Notice I'm not mentioning what should happen if the value isn't convertible to the type of your binding target. I'd expect that this model binder should act the same as others in that case (though I don't know if there is a consistent behavior, nor do I know what it is).
The case I'm really concerned about is one where the compile time type of the object is not supported by the binder - it would be nice if it would complain ASAP on that.
Thanks.
P.S. if we can agree on a desired behavior, I'd be happy to write tests and submit a patch.
The text was updated successfully, but these errors were encountered:
It would be easy to add. The reason why we generally don't do things in model binding is that we don't know if another binder (that you wrote) is going to handle it. But it's simple enough to just change the guidance and say register yours before ours
FromHeaderAttribute (from looking at the code and spending several hours debugging) seems to only support either "string" or "compatible collections" for header binding. However, sometimes the header value is just a simple int or some other similar value (in my case it was a timeout).
While I'm fine with the fact that FromHeaderAttribute doesn't support int (in my case I wanted Nullable), it would be way nicer if it somehow told you this. I don't see any sort of logging and I'm not sure what the best way to "warn" about this problem is, so I guess I'm opening up for discussion.
Personally I would have liked an exception to be thrown for an unsupported type of parameter.
Notice I'm not mentioning what should happen if the value isn't convertible to the type of your binding target. I'd expect that this model binder should act the same as others in that case (though I don't know if there is a consistent behavior, nor do I know what it is).
The case I'm really concerned about is one where the compile time type of the object is not supported by the binder - it would be nice if it would complain ASAP on that.
Thanks.
P.S. if we can agree on a desired behavior, I'd be happy to write tests and submit a patch.
The text was updated successfully, but these errors were encountered: