ASP.NET 5 Beta5来了(翻译)

在6月30日微软发布了ASP.NET 5 Beta5,我们可以从http://nuget.org上获取Beta5 的packages。

随着VS2015RC发布的ASP.NET 5的版本号是Beta4,所以你一定想在你的项目里使用这个更新。Beta5上不但修正了之前的一些问题并有了很多改进,而且还新增了很多功能。

很重要一点,我们应该知道有ASP.NET的运行时(用来运行你的网络应用)和Visual Studio上Web 工具(比如HTML、JavaScript编辑器和新文件对话框)。Beta5是对ASP.NET 5运行时的更新。

ASP.NET 5 可以运行在全功能的.NET库和核心库。.NET核心库能够运行在Windows,Azure,Linux和Mac上。是时候开始安装beta5并应用到你的ASP.NET 5项目中去。

下面是Beta 5的一些亮点:

.NET执行环境(DNX)

  • 支持Nuget v3。
    使用Nuget v3的路径可以更快地下载packages。尝试添加https://api.nuget.org/v3/index.json作为package源。
  • 支持全新的.NET目标框架监测器(TFM)。
  • 在project.json中可以设置语言和发布说明的链接
  • 消除了对JSON.NET的固定版本要求:即不再要求你的应用程序使用和DNX一致的JSON.NET版本,你可以选择新发布的JSON.NET而不需要升级DNX的版本号。
  • 新的IRuntimeEnvironment服务。使用新的Service可以获取到运行时具体信息,像OS,CLR等。

ASP.NET 5

  • HttpContext.Connection
    通过HttpContext的新加Connection属性可以获得连接的信息。
  • 新增本地化的抽象和中间件
    你可以在本地化的Sample里发现这些东西的使用。
  • 统一终止ASP.NET宿主环境的快捷键为Ctrl+C
    之前按任意键即可终止ASP.NET宿主环境的,现在统一终止快捷键为Ctrl+C。

MVC 6

  • 在Razor支持C# 6
    你可以通过MSDN上C# 6 了解C# 6的新特性。
  • 简化了MVC的选项设置,添加了顶级配置
    现在有了应用层的设置,可以用来为HTML helpers配置各种不同的设置。
  • 在视图中可以使用JSON Helper来序列化数据模型
    该功能可以让你在Razor view中非常容易地序列化你的.NET对象成JSON格式:

    @Json.Serialize(Model)
  • 在Route标记中能够使用通配替换

    [Route("Products/[action]", Name = "[actions]Products")]
    public class ProductsController
    {
        public void Add() { }
        public void Buy() { }
    }
  • 新的ImageTagHelper

    <img asp-file-version="true" src="~/images/my_cool_image.png" />  
  • Tag Helper支持绑定字典属性
    现在你可以在TagHelpers中绑定服务器端的attributes到字典属性。比如,AnchorTagHelper利用名字格式为asp-route-*的attributes来设置路由值。

    <a asp-action="Edit" asp-route-id="@index">Edit</a>
  • Tag Helper支持基于服务端attributes设置的条件绑定
    你可以利用TargetElementAttribute中Attributes属性来指定当前TagHelper应用到拥有某些attributes的tag上。比如AnchorTagHelper类的定义如下:

        [TargetElement("a", Attributes = ActionAttributeName)]
        [TargetElement("a", Attributes = ControllerAttributeName)]
        [TargetElement("a", Attributes = FragmentAttributeName)]
        [TargetElement("a", Attributes = HostAttributeName)]
        [TargetElement("a", Attributes = ProtocolAttributeName)]
        [TargetElement("a", Attributes = RouteAttributeName)]
        [TargetElement("a", Attributes = RouteValuesDictionaryName)]
        [TargetElement("a", Attributes = RouteValuesPrefix + "*")]
        public class AnchorTagHelper : TagHelper
        {
            private const string ActionAttributeName = "asp-action";
            private const string ControllerAttributeName = "asp-controller";
            private const string FragmentAttributeName = "asp-fragment";
            private const string HostAttributeName = "asp-host";
            private const string ProtocolAttributeName = "asp-protocol";
            private const string RouteAttributeName = "asp-route";
            private const string RouteValuesDictionaryName = "asp-all-route-data";
            private const string RouteValuesPrefix = "asp-route-";
            private const string Href = "href";
    
            ...
        }
    

    从上面可以看出,该TagHelper会应用到A tag上,并且这个tag上需要有asp-action, asp-controller, asp-fragment, asp-host, asp-protocol, asp-route, asp-all-route-data和asp-route-*这些attributes中一个或一个以上,否则该tag就会绑定到该TagHelper。比如

    <a href="http://www.cnblogs.com/liontone/">上善若水</a>
    

    就不会被应用上AnchorTagHelper。

大家可以在这里看到比较关于Beta5的详细的信息以及关于Beta5已知的问题。后续也会有更多的beta版本发布知道最终正式发布为止。

Beta5和Visual Studio 2015 RC是兼容的,你可以利用Visual Studio 2015 RC来打开、编译和运行基于Beta5运行库的ASP.NET 5应用。

在Visual Studio 2015RC上升级到Beta5需要做一下几步:

  • 如果之前没有安装,请安装 .NET Version Manager (DNVM)。如果已经安装了Visual Studio,请忽略这一步,直接进入下一步。
  • 设置系统环境变量DNX_FEED值为https://www.nuget.org/api/v2
  • 执行“dnvm upgrade”,升级dnx的版本号到Beta5
  • 更新应用中的global.json文件的sdk版本号到"1.0.0-beta5"(DNX)
  • 更新应用的依赖库的版本号到beta5
  • Restore新版本的依赖库
  • 编译应用并根据beta5的需要做相应的migration.

在beta5还有一些break changes,更详细的信息请参考Beta5 Release Note,希望大家能够喜欢Beta5。

时间: 2024-08-08 01:28:03

ASP.NET 5 Beta5来了(翻译)的相关文章

.NET跨平台之旅:将示例站点从ASP.NET 5 Beta5升级至Beta7

9月2日,微软发布了ASP.NET 5 Beta7(详见Announcing Availability of ASP.NET 5 Beta7).其中最大的亮点是dnx已经可以完全基于CoreCLR运行,也就是在Mac/Linux上运行dnx无需再借助Mono,而之前必须安装Mono,才能运行dnu restore安装nuget包包. 我们的ASP.NET 5跨平台示例站点 about.cnblogs.com 之前是跑在 ASP.NET 5 Beta5 上的(详见借助ASP.NET 5 Beta5

ASP.NET 5 Beta5 对TagHelper带来的变化

最近做的TagHelper项目要从原来的ASP.NET 5 Beta 4升级到Beta 5,特地整理了升级后的变化: 新增ImageTagHelper <img asp-file-version="true" src="~/images/my_cool_image.png" /> Tag Helper支持绑定字典属性现在你可以在TagHelpers中绑定服务器端的attributes到字典属性.比如,AnchorTagHelper利用名字格式为asp-r

ASP.NET 5 Beta6发布了(翻译)

感觉就好像我们刚刚发布了一个版本,现在我们又要发布一个新的版本.开发团队通过努力工作在Visual Studio2015的正式版上提交使用ASP.NET 5开发工具的上的更新以及库的更新.新的版本为beta6,它在Framework和库上新增了一系列新的功能.接下来让我们看看怎样将ASP.NET 5 beta 6添加到我们的Visual Studio 2015的安装中来. 安装 在ASP.NET 5 beta版本发布周期中第一次发布时候,我们已经发布了新版的Visual Studio web开发

asp页面无法访问,可尝试开始SQL Server等服务

存在问题 asp页面的英文提示,翻译后为: "一个错误发生在服务器在处理URL.请联系系统管理员(管理人).如果您是系统管理员,请点击这里了解更多关于这个错误." 解决方案 请开启以下两项服务: 然后重新访问asp页面.

ASP.NET 5 的Roadmap(转)

这次随 Visual Studio 2015 发布的 ASP.NET 版本是 ASP.NET 4.6 与 ASP.NET 5 beta5.在 VS2015 发布的同时,微软也发布了 ASP.NET 5 的路线图(详见 ASP.NET 5 Schedule and Roadmap): 2015 年 7 月 27 日,发布 ASP.NET 5 beta6. 2015 年 8 月 24 日,发布ASP.NET 5 beta7. 2015 年 9 月 21 日,发布 ASP.NET 5 beta8. 2

ASP.NET 5探险(6):升级ASP.NET 5到beta6

(此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:微软根据ASP.NET 5的路线图如期发布了beta6,现在我们就来说说beta5升级到beta6的一些问题. 之前微软公布了ASP.NET 5的路线图 (https://github.com/aspnet/home/wiki/roadmap).根据这个路线图的说法,在7月27日发布ASP.NET 5 beta6.由于微软是7月20日发布Visual Studio 2015 RTM的(内置AS

微软发布ASP.NET 5路线图

这次随 Visual Studio 2015 发布的 ASP.NET 版本是 ASP.NET 4.6 与 ASP.NET 5 beta5.在 VS2015 发布的同时,微软也发布了 ASP.NET 5 的路线图(详见 ASP.NET 5 Schedule and Roadmap): 2015 年 7 月 27 日,发布 ASP.NET 5 beta6. 2015 年 8 月 24 日,发布ASP.NET 5 beta7. 2015 年 9 月 21 日,发布 ASP.NET 5 beta8. 2

WEBAPI 帖子收藏

[翻译]ASP.NET Web API入门 [翻译]ASP.NET WEB API异常处理 ASP.NET WebAPI 路由规则与POST数据 ASP.NET Web API路由规则(二) ASP.NET Web API身份验证和授权

NuGet v3 feed带来的惊喜

估计有1个月了,在mac上编译dnx从来没有成功过,因为在安装nuget packages时连接myget.org总是超时. 今天在 ASP.NET 5 Beta5 Now Available 中得知 dnx 已经支持 NuGet v3 feed,而且说"Restoring packages using the new NuGet v3 feed is significantly faster". 于是将 dnx 中的 NuGet.Config 改为 v3 feed: <?xml