I work on asp.net applications 'in-house' and would love to use asp.net mvc, but am not able to as our applications are deployed to web servers that are not in our control and currently only have .net framework v2 and IIS6. As well as there being no possibility of having time/money spent on converting current WebForms applications...
我在asp.net应用程序'内部'工作,并希望使用asp.net mvc,但我无法将我们的应用程序部署到不受我们控制的Web服务器,目前只有.net framework v2和IIS6。除了没有时间/金钱用于转换当前的WebForms应用程序之外......
So any information to help me create better WebForms asp.net applications would be greatly appreciated...I've read the "what sucks" list about WebForms from the MVC people for which surely there are solutions/work-arounds to make WebForms "less sucky"...
因此,任何帮助我创建更好的WebForms asp.net应用程序的信息都将非常感激...我已经从MVC人员那里阅读了关于WebForms的“糟糕的”列表,肯定有解决方案/解决方案来制作WebForms“不那么糟糕“......
stuff that I sort of understand that could be improved (but need help on):
我理解的东西可以改进(但需要帮助):
- remove viewstate for pages that do not postback (remove the runat="server" tag?)
- 删除不回发的页面的viewstate(删除runat =“server”标签?)
- minimise usage of viewstate - using
<span><asp:literal /></span>
instead of an asp:label (we never use the style properties of server side controls but use the CssClass attribute mainly to keep CSS in the CSS files) -
最小化viewstate的使用 - 使用
而不是asp:标签(我们从不使用服务器端控件的样式属性,但主要使用CssClass属性将CSS保存在CSS文件中) - use ashx handlers for ajax requests (can this be furtherd?? e.g. a postback to a handler?)
- 使用ashx处理程序来获取ajax请求(这可以进一步吗??例如回发到处理程序?)
- can viewstate be removed completely and still postback? (is it reading the form variables instead of reading control values?)
- 可以查看状态完全删除仍然回发? (它是读取表单变量而不是读取控制值吗?)
- can you turn off the viewstate programmatically if you know the user has javascript? e.g. then an ajax request can submit the form but will work if javascript disabled?
- 如果你知道用户有javascript,你能以编程方式关闭视图状态吗?例如那么ajax请求可以提交表单但是如果禁用javascript会有效吗?
- we already keep all our business logic in a BR/BL layer and we have a similar DAL layer for database access...so aspx code behind is generally fairly light...(validation is also in the BR/BL so that responding to an ajax request or a postback for the same task requires little (or no) duplication of code)
- 我们已经将所有业务逻辑保留在BR / BL层中,并且我们有一个类似的DAL层用于数据库访问...因此后面的aspx代码通常相当轻......(验证也在BR / BL中以便响应ajax请求或同一任务的回发需要很少(或没有)重复代码)
- use of less components...(less server controls...to some degree this also means using controls that won't have the crap IDs)
- 使用较少的组件...(较少的服务器控件......在某种程度上这也意味着使用不具有垃圾ID的控件)
i don't really care for the neatly formatted URLs as its intranet based (and so pretty much irrelevant) and SEO is of no concern...even though the MVC urls look brilliant...
我并不真正关心整齐格式化的URL作为其基于内部网(并且几乎无关紧要)和SEO是无关紧要的......即使MVC网址看起来很棒......
Again, any help, resources, code samples or whatever would be awesome! thanks heaps.
再次,任何帮助,资源,代码示例或任何其他将是真棒!谢谢堆。
3 个解决方案
#1
3
Can add to this
可以添加到此
use ashx handlers for ajax requests
使用ashx处理程序来执行ajax请求
Use Jayrock to handle Ajax requests. This is very much like MVC with only JsonResult.
使用Jayrock来处理Ajax请求。这非常像只有JsonResult的MVC。
can you turn off the viewstate programmatically if you know the user has javascript
如果你知道用户有javascript,你能以编程方式关闭视图状态
You can detect if JS is enabled using this approach. Thus fairly easy to disable ViewState. Can be easily handled in base page if you have such. So the amount of repeatative code -> 0.
您可以使用此方法检测是否启用了JS。因此相当容易禁用ViewState。如果你有这样的话,可以在基页面轻松处理。所以重复代码的数量 - > 0。
Additinaly you could find WebFormsMVP helpful.
另外,你会发现WebFormsMVP很有帮助。
#2
1
For the ViewState questions, make sure you understand the difference between ViewState and ControlState. These articles helped me with that. I turn ViewState off in the web.config for my existing Webforms apps and I don't have any issues. I also avoid any of the *View controls and stick mostly to PlaceHolder, Literal, Repeater, Button, TextBox, DropDownList (can act quirky without ViewState, but nothing showstopping) and other basic controls. You can postback with ViewState off.
对于ViewState问题,请确保您了解ViewState和ControlState之间的区别。这些文章帮助了我。我在web.config中为我现有的Webforms应用程序关闭ViewState,我没有任何问题。我也避免使用任何* View控件,主要坚持PlaceHolder,Literal,Repeater,Button,TextBox,DropDownList(可以在没有ViewState的情况下表现古怪,但没有任何显示)和其他基本控件。您可以关闭ViewState进行回发。
ASHX works great for Ajax requests. I wouldn't take it any further than that though.
ASHX非常适合Ajax请求。我不会比这更进一步。
I think you're on the right track. You're already separating your layers and putting stuff where it should be and you seem to know where things should go, and knowing is half the battle.
我认为你走在正确的轨道上。你已经把你的图层分开了,并把东西放在应该的位置,你似乎知道应该去哪里,知道是成功的一半。
#3
0
Thought i'd add to this post (for when someone comes across it) the following link which is quite useful when using jQuery (or javascript for that matter):
以为我会添加到这篇文章(当有人遇到它时)以下链接,这在使用jQuery(或javascript)时非常有用:
from Rich Strahl's blog: jQuery Form Serialization without ASP.NET ViewState:
http://www.west-wind.com/weblog/posts/472329.aspx
来自Rich Strahl的博客:没有ASP.NET ViewState的jQuery表单序列化:http://www.west-wind.com/weblog/posts/472329.aspx
#1
3
Can add to this
可以添加到此
use ashx handlers for ajax requests
使用ashx处理程序来执行ajax请求
Use Jayrock to handle Ajax requests. This is very much like MVC with only JsonResult.
使用Jayrock来处理Ajax请求。这非常像只有JsonResult的MVC。
can you turn off the viewstate programmatically if you know the user has javascript
如果你知道用户有javascript,你能以编程方式关闭视图状态
You can detect if JS is enabled using this approach. Thus fairly easy to disable ViewState. Can be easily handled in base page if you have such. So the amount of repeatative code -> 0.
您可以使用此方法检测是否启用了JS。因此相当容易禁用ViewState。如果你有这样的话,可以在基页面轻松处理。所以重复代码的数量 - > 0。
Additinaly you could find WebFormsMVP helpful.
另外,你会发现WebFormsMVP很有帮助。
#2
1
For the ViewState questions, make sure you understand the difference between ViewState and ControlState. These articles helped me with that. I turn ViewState off in the web.config for my existing Webforms apps and I don't have any issues. I also avoid any of the *View controls and stick mostly to PlaceHolder, Literal, Repeater, Button, TextBox, DropDownList (can act quirky without ViewState, but nothing showstopping) and other basic controls. You can postback with ViewState off.
对于ViewState问题,请确保您了解ViewState和ControlState之间的区别。这些文章帮助了我。我在web.config中为我现有的Webforms应用程序关闭ViewState,我没有任何问题。我也避免使用任何* View控件,主要坚持PlaceHolder,Literal,Repeater,Button,TextBox,DropDownList(可以在没有ViewState的情况下表现古怪,但没有任何显示)和其他基本控件。您可以关闭ViewState进行回发。
ASHX works great for Ajax requests. I wouldn't take it any further than that though.
ASHX非常适合Ajax请求。我不会比这更进一步。
I think you're on the right track. You're already separating your layers and putting stuff where it should be and you seem to know where things should go, and knowing is half the battle.
我认为你走在正确的轨道上。你已经把你的图层分开了,并把东西放在应该的位置,你似乎知道应该去哪里,知道是成功的一半。
#3
0
Thought i'd add to this post (for when someone comes across it) the following link which is quite useful when using jQuery (or javascript for that matter):
以为我会添加到这篇文章(当有人遇到它时)以下链接,这在使用jQuery(或javascript)时非常有用:
from Rich Strahl's blog: jQuery Form Serialization without ASP.NET ViewState:
http://www.west-wind.com/weblog/posts/472329.aspx
来自Rich Strahl的博客:没有ASP.NET ViewState的jQuery表单序列化:http://www.west-wind.com/weblog/posts/472329.aspx