ASP.NET MVC Beta发布-随之而来的凉爽

ASP.NET MVC is now officially in Beta. Go get it! ScottGu has all the juicy details in his usually Epic style. In a nutshell, this is called Beta (and not Preview 1138) because the quality and the amount of testing gone into it was higher than the Previews and source drops you may have gotten off of CodePlex. It's API surface is pretty stable now.

ASP.NET MVC现在正式在Beta中。 去实现它(梦想);去得到它(东西! ScottGu具有他通常的Epic风格的所有多汁细节。 简而言之,它被称为Beta(而不是Preview 1138),因为它的质量和测试量高于您可能从CodePlex获得的Previews和源代码下降。 API的表面现在非常稳定。

Also, we're shipping jQuery with ASP.NET MVC! When you go File | New ASP.NET MVC Project, you've already got jQuery. Bam.

此外,我们还将附带ASP.NET MVC的jQuery ! 当您去File | 新的ASP.NET MVC项目,您已经有了jQuery。 am

Here's what's new in ASP.NET MVC Beta:

这是ASP.NET MVC Beta中的新增功能:

If you've been playing it safe as all the Alpha Geeks have been living on the edge, if you're wondering when would be the time to start using ASP.NET MVC or when you could go live, this is a good time to start. This release as a very clear Go-Live license. Totally, (if you haven't already) go out there and put your sites out in public on ASP.NET MVC if you like. It's pretty much feature complete (again, hence, "Beta") and shouldn't change in any major ways between now and it's release in a coming month ending in "-ber" like January-ber or Next June-ber. (Seriously, I have no idea when it'll be out. When it's done. But, we're closer than we were yesterday. Go ask Phil.)

如果您一直在安全地玩游戏,因为所有Alpha Geek都生活在边缘,如果您想知道何时开始使用ASP.NET MVC或何时可以上线,那么这是个不错的时机开始。 此版本是非常明确的Go-Live许可证。 总的来说,(如果您还没有的话)去那里,如果愿意的话,将您的网站公开发布在ASP.NET MVC上。 它几乎具有完整的功能(因此也称为“ Beta”),并且从现在到下个月以“ -ber”结尾的下个月(如January-ber或Next June-ber)发布之前,都不应有任何重大变化。 (严重的是,我不知道什么时候会结束。完成时。但是,我们比昨天更近了。去问问Phil 。)

One of the new additions is Model Binders that formalize the relationship between what's happening in HTTP and what ends up happening in your Controller actions. Similar to what you can do in MonoRail with IParameterBinder, you can now do in ASP.NET MVC. For example, back in June I showed how to handle uploaded files with ASP.NET MVC. It was useful, but hard to test and kind of hard to read.

新添加的功能之一是Model Binders,它使HTTP中发生的事情与Controller动作中最终发生的事情之间的关系正式化。 与使用IParameterBinder在MonoRail中可以执行的操作类似,现在可以在ASP.NET MVC中执行操作。 例如,六月,我展示了如何使用ASP.NET MVC处理上传的文件。 它很有用,但是很难测试并且很难阅读。

Here's a cleaner way as an example from Levi Broderick, a Developer on the ASP.NET MVC team.

作为ASP.NET MVC团队的开发人员Levi Broderick的示例,这是一种更简洁的方法。

A Sample ModelBinder for HttpPostedFileBase:

HttpPostedFileBase的示例ModelBinder:

public class HttpPostedFileBaseModelBinder : IModelBinder {

public ModelBinderResult BindModel(ModelBindingContext bindingContext) {
HttpPostedFileBase theFile = bindingContext.HttpContext.Request.Files[bindingContext.ModelName];
return new ModelBinderResult(theFile);
}
}

You'd activate it in your global.asax.cs (or .vb):

您可以在global.asax.cs(或.vb)中激活它:

ModelBinders.Binders[typeof(HttpPostedFileBase)] = new HttpPostedFileBaseModelBinder();

Then you'd make sure the form in your view uses the correct enctype:

然后,请确保您视图中的表单使用正确的enctype:


<form enctype="multipart/form-data" method="post" action="{some url}">
Choose file: <input name="theFile" type="file">
<input value="Submit Query" type="submit">
</form>

…and finally, in the action method of your controller:

…最后,在控制器的操作方法中:

public ActionResult Upload(HttpPostedFileBase theFile) {

// 'theFile' now contains the uploaded file
}

That's it. There's lots of cool binding stuff you can do, but that's just one example.

而已。 您可以做很多很酷的绑定工作,但这只是一个例子。

One other thing I wanted to say. I was in Las Vegas yesterday keynoting VSLive and I made it a point to show this new slide. It's simple, and perhaps obvious, but perhaps not:

我想说的另一件事。 昨天我在拉斯维加斯给VSLive作主题演讲,并着重介绍了这张新幻灯片。 这很简单,也许很明显,但可能并非如此:

I wanted to make it clear that even though folks (and me) might use the term "hybrid" to refer to ASP.NET applications that mix WebForms, MVC and Dynamic Data, that these are all just ASP.NET. Arguably ASP.NET Ajax and the Ajax Controls could be either another circle or part of the larger one.

我想弄清楚,即使人们(和我)可能使用术语“混合”来指代混合了WebForms,MVC和Dynamic Data的ASP.NET应用程序,但它们全都是ASP.NET。 可以说,ASP.NET Ajax和Ajax控件可以是另一个圆圈,也可以是较大圆圈的一部分。

I also showed ASP.NET+Dynamic Data that you'll be hearing more about at PDC and even more next year. You should feel free to use these subsystems as you like, mix and match, promote and ignore. Whatever makes you happy. All the ASP.NET core stuff like Authentication, Authorization, Session, Caching, etc, that all works in all of these subsystems because they are all ASP.NET.

我还向您展示了ASP.NET +动态数据,您将在PDC以及明年获得更多信息。 您应该随心所欲地使用这些子系统,进行混合,匹配,升级和忽略。 令您开心的事。 所有ASP.NET核心内容(例如Authentication,Authorization,Session,Caching等)都可以在所有这些子系统中使用,因为它们都是ASP.NET

Wow, that kind of sounded like a political speech! "Can't we all just get along? MVC and WebForms living together, with Dynamic Data by their side..."

哇,听起来像是一场政治演讲! “我们不能就此相处吗?MVC和WebForms一起生活,而动态数据则在他们身边……”

Enjoy.

请享用。

翻译自: https://www.hanselman.com/blog/aspnet-mvc-beta-released-coolness-ensues

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值