English 中文(简体)
在 ASP.NET MVC 中查询 C # 对象的查询字符串
原标题:Query String to C# Object in ASP.NET MVC

我有一个非常普通的问题。

当与 ASP.NET MVC 开发时。 它提供了一个很好的方法来利用 C # 与客户端对象如查询字符串互动 。

我想知道 ASP.NET MVC 框架如何将 Get 请求中的查询字符串或 POST 请求中的表格数据转换为强烈输入 C# 类? 是否有特定的 HttpHandler 或 HtpModules 用于此操作? 或者它们是否使用任何预先定义的行动过滤器?

我想在以周转基金为基础的RESTFulll服务中执行类似的功能,我认为我需要为此目的使用拦截器。

请提供一些咨询意见。

感谢前台

最佳回答

您指的是 < a href=> http://msdn.microsoft.com/ en- us/library/dd41405.aspx" rel=“nofollow” >ASP.NET MVC 模型装订。 这实际上与 ActionFilters 或 HttpModules 相比,是框架的一个完全独立的部分。 它通过审查“价值提供者” - 请求中的信息来源, 如窗体数据、查询字符串, 甚至路径 - 并尝试用名称将其匹配到控制器动作中的复杂类型属性 。

Kenneth提到,您可以在CodePlex 上查看源代码,但是,如果您想使用“reful 建筑图案”来撰写服务,您可以开始使用“a href=” http://www.asp.net/web-api” rel=“nofollow”>>Web API 的MVC4 beta中,该图案也支持装订模型(所以您不必重新发明它! )

还值得一提的是,网络API是为WCF开发的,但现已成为的一部分?标题:WCF%20Web%20API%20is%20now%20ASP.NET%20Web%20API" rel=“nofollow”ASP.NET MVC ,这是有道理的,因为ASP.NET MVC和网络API一样,MVC主要围绕HTTP建造。

问题回答

我不太熟悉可扩展模式, 但在 mvc3 的一面, 所有源都在那里。 您可以看到模式是如何执行的。 只要下载源, 其读数相当丰富 。

http://aspnet.codeplex.com/releases/view 58781, rel=“no follow'>http://aspnet.codeplex.com/releases/view 58781





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签