为ASP.NET MVC 1 ASP.NET MVC 2向前兼容? [英] Is ASP.NET MVC 1 forwards compatible with ASP.NET MVC 2?

查看:108
本文介绍了为ASP.NET MVC 1 ASP.NET MVC 2向前兼容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以运行使用MVC 2组件顺利MVC模式1的应用程序?据我了解,有些第三方工具有东西在MVC 2打破,但我们我不使用其他任何工具承担。

Can I run a MVC 1 application using the MVC 2 assemblies without a hitch? I understand that some 3rd party tools have had stuff broken in MVC 2, but let's assume I'm not using those any other tools.

推荐答案

有过重大更改

如果你想有一个1.0的项目在运行2.0,但它寻找在不同的地方的东西; <一href=\"http://weblogs.asp.net/leftslipper/archive/2009/10/19/migrating-asp-net-mvc-1-0-applications-to-asp-net-mvc-2.aspx\"相对=nofollow>所以你必须给应用程序迁移到2.0。。

If you want a 1.0 project to run on 2.0, it does look for things in different places; so you'd have to migrate the application to 2.0..

下面是改变那些可能'破发'(电流preVIEW 2):

Here are the changes that could possibly 'break' (current as of Preview 2):

在preVIEW变化2

为了充分利用新的HTML编码前pression语法在ASP.NET 4中,HTML辅助的返回类型现在是 MvcHtmlString 代替一个字符串。请注意,如果您使用ASP.NET MVC 2和ASP.NET 3.5的新助手,你将不能够利用HTML编码语法;新的语法只适用于当您运行ASP.NET 4 ASP.NET MVC 2

In order to take advantage of the new HTML-encoding expression syntax in ASP.NET 4, the return type of the HTML helpers is now MvcHtmlString instead of a string. Note that if you use ASP.NET MVC 2 and the new helpers with ASP.NET 3.5, you will not be able to take advantage of the HTML-encoding syntax; the new syntax is available only when you run ASP.NET MVC 2 on ASP.NET 4.

为了减轻对信息披露的潜在JSON劫持攻击,默认情况下, JsonResult 类现在只响应HTTP POST 请求。 AJAX开始动手方法返回一个 JsonResult 对象应改为使用POST调用。如果有必要,你可以通过设置新的 JsonRequestBehavior JsonResult 属性来覆盖此行为。有关潜在的更多信息漏洞,请参阅博客文章JSON劫持上菲尔哈克的博客。

In order to mitigate JSON hijacking attacks that have the potential for information disclosure, by default, the JsonResult class now responds only to HTTP POST requests. AJAX GET calls to action methods that return a JsonResult object should be changed to use POST instead. If necessary, you can override this behavior by setting the new JsonRequestBehavior property of JsonResult. For more information about the potential exploit, see the blog post JSON Hijacking on Phil Haack’s blog.

一个新的可设置 ModelMetadata 属性已被添加到 ModelBindingContext 类。新属性封装了模型和 ModelType 属性。虽然模式 ModelType 属性过时,为了向后兼容的特性依然干将工作;他们委托给 ModelMetadata 属性检索值。

A new settable ModelMetadata property has been added to the ModelBindingContext class. The new property encapsulates both the Model and the ModelType properties. Although the Model and ModelType properties are obsolete, for backward compatibility the property getters still work; they delegate to the ModelMetadata property to retrieve the value.

在preVIEW变化1

这变化影响,从 DefaultControllerFactory 获得定制控制器工厂。该DefaultControllerFactory类固定通过删除 RequestContext的财产,而不是传递请求上下文实例的受保护的虚拟方法 GetControllerInstance GetControllerType

This change affects custom controller factories that derive from DefaultControllerFactory . The DefaultControllerFactory class was fixed by removing the RequestContext property and instead passing the request context instance to the protected virtual methods GetControllerInstance and GetControllerType.

要更新自定义控制器工厂,以支持ASP.NET MVC 2,改变方法签名或签名,以匹配新的签名,并使用请求上下文参数,而不是属性。

To update the custom controller factories to support ASP.NET MVC 2, change the method signature or signatures to match the new signatures, and use the request context parameter instead of the property.

在路径的值的字符串区目前已在ASP.NET MVC特殊的含义,以同样的方式,控制器和行动做的。一个含义是,如果HTML佣工含区域的路线值字典提供,该助手将不再在查询字符串追加区域。

The string "area" in Route values now has special meaning in ASP.NET MVC, in the same way that "controller" and "action" do. One implication is that if HTML helpers are supplied with a route-value dictionary containing "area", the helpers will no longer append "area" in the query string.

如果您使用的是区域功能,确保不使用 {地区} 作为路线URL的一部分。

If you are using the Areas feature, make sure to not use {area} as part of your route URL.

已知问题

添加视图对话框抛出时创建强类型的视图复选框被选中,一个视图内容的选择不是空的其他选择一个NullReferenceException,并为一个类型,确实存在被指定视图数据类类型名称。当指定类型的名称,可以使用下拉列表中选择类型名称或键入完​​全限定的类型名称。对于不存在的类型,你必须设置查看内容为空。

The Add View dialog box throws a NullReferenceException when the Create strongly-typed view check box is checked, a View Content selection other than "Empty" is selected, and a View data class type name is specified for a type that does exist. When specifying a type name, either use the drop-down list to select the type name or type the fully-qualified type name. For types that do not exist, you must set View Content to "Empty".

这篇关于为ASP.NET MVC 1 ASP.NET MVC 2向前兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆