简体   繁体   English

将ExtJS与ASP.NET,Webforms或MVC一起使用?

[英]Using ExtJS with ASP.NET, Webforms or MVC?

For a scenario using 0 ASP.NET controls at all but rather an 100% extJS interface, what would be the advantages of using ASP.NET MVC or ASP.NET WebForms? 对于使用0个ASP.NET控件而非100%extJS接口的场景,使用ASP.NET MVC或ASP.NET WebForms会有什么好处? And the disadvantages? 而且缺点呢? Is there a OBVIOUS way to do it properly? 有没有一种合适的方法来正确地做到这一点?

I would love to have feedback's on your experiences. 我很想得到关于你的经历的反馈。

Thank you! 谢谢!

WebForms + any purely client-side framework will give you nothing but endless headaches, if you can get it working at all. WebForms +任何纯粹的客户端框架都会给你带来无穷无尽的麻烦,如果你可以让它工作的话。 Some of the issues I've had in the past (off the top of my head, it's been a while): 我过去遇到过的一些问题(在我的脑海中,已经有一段时间了):

  • WebForms limits you to a single <form> tag per page. WebForms将您限制为每页一个<form>标记。 While this does not necessarily prevent use of Ext or something like it, it is severely (and arbitrarily) limiting in many cases 虽然这并不一定妨碍使用Ext或类似的东西,但在许多情况下严重(并且任意)限制
  • WebForms is built around postbacks and viewstate. WebForms是围绕回发和视图状态构建的。 Assuming that you aren't using those features (since you have no server controls) you'll be fighting against the way WebForms wants to work. 假设您没有使用这些功能(因为您没有服务器控件),您将会遇到WebForms想要工作的方式。 You can do this, but things really quickly turn hacky. 你可以做到这一点,但事情真的很快变成黑客。
  • WebForms has an entire page lifecycle and server-side event framework. WebForms具有整个页面生命周期和服务器端事件框架。 Again, since you won't be using any of that, what's the point in picking WebForms? 同样,既然你不会使用其中任何一个,那么选择WebForms有什么意义呢?
  • You're stuck with nasty urls unless you want to really fight with IIS. 除非你想真正与IIS战斗,否则你会被困在讨厌的网址中。

ASP.Net MVC is a much better alternative if you still want to take advantage of what .NET can offer on the server side without the misery that is WebForms. ASP.Net MVC是一个更好的选择,如果你仍然希望利用.NET可以在服务器端提供什么而不会有WebForms的痛苦。 There are also several different Ext.Direct providers for MVC available in the Ext forums if you search. 如果您搜索,还可以在Ext论坛中使用几种不同的Ext.Direct提供程序。 Good luck finding anything out there to help you integrate Ext with WebForms (there is nothing). 祝你好好找到任何东西来帮助你将Ext与WebForms集成(没有任何东西)。

EDIT : I've been using this implementation of the Ext.Direct stack for ASP.NET MVC for a while with excellent results. 编辑 :我一直在使用这个 Ext.Direct堆栈的实现为ASP.NET MVC一段时间有很好的结果。

Consider building your Ext JS front-end in isolation from the server. 考虑与服务器隔离构建Ext JS前端。

This decoupling forces you to create a pure javascript application, and keeps you far away from the issues introduced by the "helpers" in various frameworks. 这种解耦迫使您创建一个纯粹的JavaScript应用程序,并使您远离各种框架中“帮助者”引入的问题。

It reduces the amount of time you'll be "shifting gears" between server-side languages and javascript. 它减少了你在服务器端语言和javascript之间“转换”的时间。 In my experience, especially for developers new to Ext JS, the single biggest hurdle is in separating the front-end logic from the server-side logic. 根据我的经验,特别是对于刚接触Ext JS的开发人员来说,最大的障碍是将前端逻辑与服务器端逻辑分开。

And it will be blazing fast! 它会很快! Communicate with the server using pure HTTP and JSON and build an Ext JS application as it was intended! 使用纯HTTP和JSON与服务器通信,并按照预期构建Ext JS应用程序!

For that I would tend to use the MVC style of ASP. 为此,我倾向于使用ASP的MVC风格。 Basically it is because ASP.net tends to add random junk you don't need. 基本上是因为ASP.net倾向于添加你不需要的随机垃圾。 What you want is the purest cleanest thing to push data out to ExtJS. 你想要的是将数据推送到ExtJS最纯粹最干净的东西。 If you don't need any server interaction at all, say you're sending any entered back to Azure or S3, then you don't need any ASP at all you can sent static HTML. 如果您根本不需要任何服务器交互,比如说您要将任何输入回送到Azure或S3,那么您根本不需要任何ASP就可以发送静态HTML。

ASP.Net MVC would be better for integrating with ExtJs. ASP.Net MVC可以更好地与ExtJs集成。 If you have to use Web Forms, then I would suggest to take a look at http://www.coolite.com/ . 如果您必须使用Web窗体,那么我建议您查看http://www.coolite.com/ This is a ASP.Net wrapper over ExtJs and will probably make life easier. 这是一个基于ExtJs的ASP.Net包装器,可能会让生活更轻松。

Another perspective: I am building a web client in extjs for a domain-specific .NET server remoting. 另一个观点:我正在extjs中构建一个Web客户端,用于特定于域的.NET服务器远程处理。 I guess I could basically just push "raw" data to ext as the server app handles all logic, but as my remoting is not "web-aware", I am using a set of custom http handlers (.ashx) to parse parameters and set mime-types, session handling and all that web-server related stuff. 我想我基本上可以将“原始”数据推送到ext,因为服务器应用程序处理所有逻辑,但由于我的远程处理不是“网络感知”,我使用一组自定义http处理程序(.ashx)来解析参数和设置mime-types,会话处理和所有与web-server相关的东西。 With this architecture its working very well with just a few.ashx scripts, I dont feel any need to use a fancier setup like ASP.NET MVC (I dont even think that would fit), but I'm not using WebForms either. 有了这个架构,它只需要几个.ashx脚本,我不觉得有任何需要使用像ASP.NET MVC这样的更高级的设置(我甚至认为不合适),但我也没有使用WebForms。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM