Asp.net单页应用程序:如何检查帖子数据?Request对象的哪个属性?

Asp.net single page application: How to examine post data? which property of the Request object?
2021-06-10
  •  译文(汉语)
  •  原文(英语)

如何检查通过Ajax请求提交的帖子数据?它在请求对象中吗?如果是,哪个属性?谢谢!

速聊1:
请提供更多详细信息,并告诉我您尝试了什么以及出现了什么问题?
速聊2:
您将像检查其他任何请求的POST数据一样对其进行检查.它可以在Request对象中,也可以在MVC动作方法参数中,在FormCollection等等中.您尝试了什么?
速聊3:
抱歉,您的问题未明确.我正在使用淘汰赛和asp.net单页应用程序.我在JavaScript中调用了$ .ajax(url,options).(在我的选项中,我有一个属性"数据",应该是一个名为Person的JavaScript对象,与我的C#代码中的模型相对应.在我的apipersonler PersonController中,我有一个名为PostPerson的操作,该操作将Person作为对象(Person类已定义问题是从不调用此控制器操作,而是仅创建和处理dbContext,然后调用伪构造函数Person(){}.
速聊4:
很抱歉没有提出明确的问题.我不知道为什么我的apicontroller中没有调用我的控制器动作.我通过Ajax调用传递的数据未进行反序列化,而是映射到了c#(可能是Person类)中的相应对象中.因此,我想查看传递给服务器端的数据,查看其格式是否正确,甚至可能为null.谢谢

How do I examine the post data submitted through Ajax request? Is it in the Request object? if yes, which property? Thanks!

Talk1:
Please give more details and tell me what you tried and what's your problem ?
Talk2:
You'd examine it like the POST data of any other request. It can be in the Request object, it can be in MVC action method parameters, in a FormCollection, etc. What have you tried?
Talk3:
Sorry for not making the question clear. I am using knockout, and asp.net single page application. I called $.ajax(url, options) in my javascript. (where in my options, I have property "data" that's supposed to be an javascript object called Person corresponding to model in my c# code. In my apicontroller PersonController, I have action called PostPerson that takes a Person as an object (Person class defined in Person.cs). The problem is this controller action is never called. Instead, only the dbContext is created and disposed, dummy constructor Person(){} is called.
Talk4:
Sorry for not asking clear question. I don't know why my controller action is not called in my apicontroller. The data I passed with Ajax call is not deserialized and mapped into the corresponding object in c# (perhaps), which is Person class. Thus I want to see the data that I passed to server side, see if it's in the right format, or perhaps even null. Thanks
Solutions1

The POST data is in

Request.Form

http://msdn.microsoft.com/en-us/library/ms525985(v=vs.90).aspx

转载于:https://stackoverflow.com/questions/19081516/asp-net-single-page-application-how-to-examine-post-data-which-property-of-the

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入