阅读状态描述响应

时间:2016-07-24 04:06:07

标签: json asp.net-mvc rest polymer

我正在使用Polymer和ASP.NET MVC 5(无Web API)。我正在使用iron-form来处理一些AJAX请求。

每当提交表单时,其响应都会记录在事件监听器铁形错误或铁形式响应中。

除了一件小事之外,一切都运行得非常好:我希望收到我发送给客户的说明。到目前为止,它出现的唯一地方是“响应”,而不是事件监听器收到的实际对象。

如何发送描述或消息以使其可以在对象中以便我可以阅读?

以下是方法:(服务器)

public async Task<ActionResult> Login(Login model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return new HttpStatusCodeResult((HttpStatusCode)422);
            }
            var result = await auth.Login(model);

            switch (result)
            {
                case LoginResultEnum.LoginSuccessful:
                    return new HttpStatusCodeResult(HttpStatusCode.NoContent); //204
                //http://stackoverflow.com/a/38007220/1057052
                case LoginResultEnum.EmailConfirmationResent:

                    return new HttpStatusCodeResult(HttpStatusCode.Accepted,Localization.Language.Account_Login_EmailResent);
            }
            //case LoginResultEnum.UserNotFound: I've removed this from the switch statement..
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest, Localization.Language.Account_Login_Fail);
        }

来自开发工具:

Object {request: iron-request, error: Error: The request failed with status code: 400 at iron-request.<anonymous> (https://localhost:4…}
error
:
Error: The request failed with status code: 400 at iron-request.<anonymous> (https://localhost:44345/NodeJS/Polymer/app/bower_components/iron-ajax/iron-request.html:234:32)
message
:
"The request failed with status code: 400"
stack
:
(...)
get stack
:
stack()
set stack
:
stack()
__proto__
:
Object
request
:
iron-request
__data__
:
Object
__dom
:
null
__domApi
:
DomApi
__polymerGestures
:
null
_aboveConfig
:
Object
_clients
:
null
_clientsReadied
:
true
_config
:
Object
_customStyle
:
null
_debouncers
:
Object
_handlers
:
Array[0]
_ownStyleProperties
:
null
_ownerShadyRoot
:
undefined
_readied
:
true
_scopeSelector
:
null
_styleCache
:
null
_styleProperties
:
null
aborted
:
false
accessKey
:
""
attributes
:
NamedNodeMap
0
:
hidden
length
:
1
__proto__
:
NamedNodeMap
constructor
:
NamedNodeMap()
getNamedItem
:
getNamedItem()
getNamedItemNS
:
getNamedItemNS()
item
:
item()
length
:
(...)
get length
:
()
removeNamedItem
:
removeNamedItem()
removeNamedItemNS
:
removeNamedItemNS()
setNamedItem
:
setNamedItem()
setNamedItemNS
:
setNamedItemNS()
Symbol(Symbol.iterator)
:
values()
Symbol(Symbol.toStringTag)
:
"NamedNodeMap"
__proto__
:
Object
baseURI
:
"https://localhost:44345/"
childElementCount
:
0
childNodes
:
NodeList[0]
children
:
HTMLCollection[0]
classList
:
DOMTokenList[0]
className
:
""
clientHeight
:
0
clientLeft
:
0
clientTop
:
0
clientWidth
:
0
completes
:
Promise
__proto__
:
Promise
[[PromiseStatus]]
:
"rejected"
[[PromiseValue]]
:
Error: The request failed with status code: 400 at iron-request.<anonymous> (https://localhost:44345/NodeJS/Polymer/app/bower_components/iron-ajax/iron-request.html:234:32)
message
:
"The request failed with status code: 400"
stack
:
(...)
get stack
:
stack()
arguments
:
null
caller
:
null
length
:
0
name
:
"get stack"
__proto__
:
()
apply
:
apply()
arguments
:
(...)
get arguments
:
ThrowTypeError()
arguments
:
null
caller
:
null
length
:
0
__proto__
:
()
apply
:
apply()
arguments
:
(...)
get arguments
:
ThrowTypeError()
set arguments
:
ThrowTypeError()
bind
:
bind()
call
:
call()
caller
:
(...)
get caller
:
ThrowTypeError()
set caller
:
ThrowTypeError()
constructor
:
Function()
length
:
0
name
:
""
toString
:
toString()
Symbol(Symbol.hasInstance)
:
[Symbol.hasInstance]()
__proto__
:
Object
<function scope>
<function scope>
set arguments
:
ThrowTypeError()
bind
:
bind()
call
:
call()
caller
:
(...)
get caller
:
ThrowTypeError()
set caller
:
ThrowTypeError()
constructor
:
Function()
length
:
0
name
:
""
toString
:
toString()
Symbol(Symbol.hasInstance)
:
[Symbol.hasInstance]()
__proto__
:
Object
<function scope>
<function scope>
set stack
:
stack()
__proto__
:
Object
contentEditable
:
"inherit"
customStyle
:
Object
dataHost
:
undefined
dataset
:
DOMStringMap
dir
:
""
domHost
:
null
draggable
:
false
errored
:
false
firstChild
:
null
firstElementChild
:
null
hidden
:
true
id
:
""
innerHTML
:
""
innerText
:
""
isConnected
:
false
isContentEditable
:
false
lang
:
""
lastChild
:
null
lastElementChild
:
null
localName
:
"iron-request"
namespaceURI
:
"http://www.w3.org/1999/xhtml"
nextElementSibling
:
null
nextSibling
:
null
nodeName
:
"IRON-REQUEST"
nodeType
:
1
nodeValue
:
null
offsetHeight
:
0
offsetLeft
:
0
offsetParent
:
null
offsetTop
:
0
offsetWidth
:
0
onabort
:
null
onbeforecopy
:
null
onbeforecut
:
null
onbeforepaste
:
null
onblur
:
null
oncancel
:
null
oncanplay
:
null
oncanplaythrough
:
null
onchange
:
null
onclick
:
null
onclose
:
null
oncontextmenu
:
null
oncopy
:
null
oncuechange
:
null
oncut
:
null
ondblclick
:
null
ondrag
:
null
ondragend
:
null
ondragenter
:
null
ondragleave
:
null
ondragover
:
null
ondragstart
:
null
ondrop
:
null
ondurationchange
:
null
onemptied
:
null
onended
:
null
onerror
:
null
onfocus
:
null
oninput
:
null
oninvalid
:
null
onkeydown
:
null
onkeypress
:
null
onkeyup
:
null
onload
:
null
onloadeddata
:
null
onloadedmetadata
:
null
onloadstart
:
null
onmousedown
:
null
onmouseenter
:
null
onmouseleave
:
null
onmousemove
:
null
onmouseout
:
null
onmouseover
:
null
onmouseup
:
null
onmousewheel
:
null
onpaste
:
null
onpause
:
null
onplay
:
null
onplaying
:
null
onprogress
:
null
onratechange
:
null
onreset
:
null
onresize
:
null
onscroll
:
null
onsearch
:
null
onseeked
:
null
onseeking
:
null
onselect
:
null
onselectstart
:
null
onshow
:
null
onstalled
:
null
onsubmit
:
null
onsuspend
:
null
ontimeupdate
:
null
ontoggle
:
null
onvolumechange
:
null
onwaiting
:
null
onwebkitfullscreenchange
:
null
onwebkitfullscreenerror
:
null
onwheel
:
null
outerHTML
:
"<iron-request hidden=""></iron-request>"
outerText
:
""
ownerDocument
:
document
parentElement
:
null
parentNode
:
null
prefix
:
null
previousElementSibling
:
null
previousSibling
:
null
progress
:
Object
rejectCompletes
:
t()
resolveCompletes
:
s()
response
:
null
root
:
iron-request
__data__
:
Object
aborted
:
false
completes
:
Promise
errored
:
false
progress
:
Object
response
:
null
status
:
400
statusText
:
""
timedOut
:
false
xhr
:
XMLHttpRequest
__dom
:
null
__domApi
:
DomApi
__polymerGestures
:
null
_aboveConfig
:
Object
_clients
:
null
_clientsReadied
:
true
_config
:
Object
_customStyle
:
null
_debouncers
:
Object
_handlers
:
Array[0]
_ownStyleProperties
:
null
_ownerShadyRoot
:
undefined
_readied
:
true
_scopeSelector
:
null
_styleCache
:
null
_styleProperties
:
null
aborted
:
false
accessKey
:
""
attributes
:
NamedNodeMap
baseURI
:
"https://localhost:44345/"
childElementCount
:
0
childNodes
:
NodeList[0]
children
:
HTMLCollection[0]
classList
:
DOMTokenList[0]
className
:
""
clientHeight
:
0
clientLeft
:
0
clientTop
:
0
clientWidth
:
0
completes
:
Promise
contentEditable
:
"inherit"
customStyle
:
Object
dataHost
:
undefined
dataset
:
DOMStringMap
dir
:
""
domHost
:
null
draggable
:
false
errored
:
false
firstChild
:
null
firstElementChild
:
null
hidden
:
true
id
:
""
innerHTML
:
""
innerText
:
""
isConnected
:
false
isContentEditable
:
false
lang
:
""
lastChild
:
null
lastElementChild
:
null
localName
:
"iron-request"
namespaceURI
:
"http://www.w3.org/1999/xhtml"
nextElementSibling
:
null
nextSibling
:
null
nodeName
:
"IRON-REQUEST"
nodeType
:
1
nodeValue
:
null
offsetHeight
:
0
offsetLeft
:
0
offsetParent
:
null
offsetTop
:
0
offsetWidth
:
0
onabort
:
null
onbeforecopy
:
null
onbeforecut
:
null
onbeforepaste
:
null
onblur
:
null
oncancel
:
null
oncanplay
:
null
oncanplaythrough
:
null
onchange
:
null
onclick
:
null
onclose
:
null
oncontextmenu
:
null
oncopy
:
null
oncuechange
:
null
oncut
:
null
ondblclick
:
null
ondrag
:
null
ondragend
:
null
ondragenter
:
null
ondragleave
:
null
ondragover
:
null
ondragstart
:
null
ondrop
:
null
ondurationchange
:
null
onemptied
:
null
onended
:
null
onerror
:
null
onfocus
:
null
oninput
:
null
oninvalid
:
null
onkeydown
:
null
onkeypress
:
null
onkeyup
:
null
onload
:
null
onloadeddata
:
null
onloadedmetadata
:
null
onloadstart
:
null
onmousedown
:
null
onmouseenter
:
null
onmouseleave
:
null
onmousemove
:
null
onmouseout
:
null
onmouseover
:
null
onmouseup
:
null
onmousewheel
:
null
onpaste
:
null
onpause
:
null
onplay
:
null
onplaying
:
null
onprogress
:
null
onratechange
:
null
onreset
:
null
onresize
:
null
onscroll
:
null
onsearch
:
null
onseeked
:
null
onseeking
:
null
onselect
:
null
onselectstart
:
null
onshow
:
null
onstalled
:
null
onsubmit
:
null
onsuspend
:
null
ontimeupdate
:
null
ontoggle
:
null
onvolumechange
:
null
onwaiting
:
null
onwebkitfullscreenchange
:
null
onwebkitfullscreenerror
:
null
onwheel
:
null
outerHTML
:
"<iron-request hidden=""></iron-request>"
outerText
:
""
ownerDocument
:
document
parentElement
:
null
parentNode
:
null
prefix
:
null
previousElementSibling
:
null
previousSibling
:
null
progress
:
Object
rejectCompletes
:
t()
resolveCompletes
:
s()
response
:
null
root
:
iron-request
scrollHeight
:
0
scrollLeft
:
0
scrollTop
:
0
scrollWidth
:
0
shadowRoot
:
null
shadyRoot
:
null
spellcheck
:
true
status
:
400
statusText
:
""
style
:
CSSStyleDeclaration
succeeded
:
false
tabIndex
:
-1
tagName
:
"IRON-REQUEST"
textContent
:
""
timedOut
:
false
title
:
""
translate
:
true
url
:
"/api/Account/Login"
webkitdropzone
:
""
xhr
:
XMLHttpRequest
__proto__
:
HTMLElement
scrollHeight
:
0
scrollLeft
:
0
scrollTop
:
0
scrollWidth
:
0
shadowRoot
:
null
shadyRoot
:
null
spellcheck
:
true
status
:
400
statusText
:
""
style
:
CSSStyleDeclaration
succeeded
:
false
tabIndex
:
-1
tagName
:
"IRON-REQUEST"
textContent
:
""
timedOut
:
false
title
:
""
translate
:
true
url
:
"/api/Account/Login"
webkitdropzone
:
""
xhr
:
XMLHttpRequest
_responseType
:
"json"
onabort
:
null
onerror
:
null
onload
:
null
onloadend
:
null
onloadstart
:
null
onprogress
:
null
onreadystatechange
:
null
ontimeout
:
null
readyState
:
4
response
:
null
responseType
:
"json"
responseURL
:
"https://localhost:44345/api/Account/Login"
status
:
400
statusText
:
""
timeout
:
0
upload
:
XMLHttpRequestUpload
withCredentials
:
false
__proto__
:
XMLHttpRequest
__proto__
:
HTMLElement
__proto__
:
Object

0 个答案:

没有答案