首页 \ 问答 \ 执行服务器端验证的正确REST方法是什么?(What is the correct REST method for performing server side validation?)

执行服务器端验证的正确REST方法是什么?(What is the correct REST method for performing server side validation?)

如果我不想更新资源,但我只想检查某些内容是否有效(在我的情况下,是一个SQL查询),那么正确的REST方法是什么?

我还没有获得资源。 我还没有PUT,发布或修补任何东西。 我只是将表单的一部分发送回来进行验证,只有服务器可以做。 另一个等价物是检查密码是否符合只能由域知道的复杂性要求,或者可能还有其他用例。

发送对象,验证,返回响应,继续表单。 使用REST。 有任何想法吗? 我错过了什么吗?


If I don't want to update a resource, but I just want to check if something is valid (in my case, a SQL query), what's the correct REST method?

I'm not GETting a resource (yet). I'm not PUTting, POSTing, or PATCHing anything (yet). I'm simply sending part of a form back for validation that only the server can do. Another equivalent would be checking that a password conforms to complexity requirements that can only be known by the domain, or perhaps there are other use cases.

Send object, validate, return response, continue with form. Using REST. Any ideas? Am I missing something?


原文:https://stackoverflow.com/questions/47860995
更新时间:2024-01-18 07:01

最满意答案

您附加的财产注册是错误的。 ownerTypeExtender ,而不是DependencyObject

public static readonly DependencyProperty AttachedTextProperty = 
    DependencyProperty.RegisterAttached(
        "AttachedText",
        typeof(string),
        typeof(Extender), // here
        new PropertyMetadata(string.Empty));

请参阅RegisterAttached的MSDN文档:

ownerType - 正在注册依赖项属性的所有者类型


Your attached property registration is wrong. The ownerType is Extender, not DependencyObject.

public static readonly DependencyProperty AttachedTextProperty = 
    DependencyProperty.RegisterAttached(
        "AttachedText",
        typeof(string),
        typeof(Extender), // here
        new PropertyMetadata(string.Empty));

See the MSDN documentation for RegisterAttached:

ownerType - The owner type that is registering the dependency property

相关问答

更多
  • 您确定正在创建ChatTabView不同实例吗? 我相信WPF的TabControl重新使用现有模板,如果它是相同的而不是创建一个新模板,只需替换它背后的DataContext 。 因此,它只会创建一个ChatTabView副本,并且切换标签正在将ChatTabView后面的DataContext替换为ChatTabView中的其他项目。 Are you sure there are different instances of your ChatTabView being created? I belie ...
  • 当我关闭用户控件时,由于没有对象引用它,附加属性将被缩回。 这是错误的。 如果您删除了取消注册事件的代码,那么使用附加属性的任何控件都将永远存在。 为什么? 因为你注册的事件处理程序是静态的。 这意味着控件将包含对静态垃圾收集器无法收集的静态内容的引用。 解决这个问题的第一个可能的解决方案是在注册事件时使用弱事件模式。 正是由于上述原因,我在注册自己附属属性的事件时总是使用弱事件模式。 这个解决方案令人讨厌的是它需要相当大量的样板代码。 您必须为每种新类型的事件创建一个新的WeakEventManager实 ...
  • 好吧,我认为@King King对于To和From属性是正确的,并且使用触发器实现了相同的功能。 如果有人需要,这是风格。