eWorld.UI - Matt Hawley

Ramblings of Matt

ASP.NET MVC Preview 4 New Finds

July 17, 2008 00:49 by matthaw

So I've been checking over the source code for the latest ASP.NET MVC P4 release out on CodePlex, and have found some very interesting things.

 1. There's a variant codebase that is very similar to my RedirectToAction via Lambda expressions contained within the Futures/MvcFutures/Internal directory, "ExpressionHelper.cs". With this futures drop, the call will return a RouteValueDictionary, in which you turn around and call RedirectToRoute. In my version, of RedirectToAction, this is all taken care of for you, as well as it supports not having to explicitly give the type of your controller. Either way, here's the example on how to use this if you prefer:

   1:  using Microsoft.Web.Mvc.Internal;
   2:  using System.Web.Routing;
   3:   
   4:  public class HomeController : Controller
   5:  {
   6:     public ActionResult Index()
   7:     {
   8:        return View();
   9:     }
  10:   
  11:     public ActionResult DoRedirect()
  12:     {
  13:        RouteValueDictionary values = 
  14:           ExpressionHelper.GetRouteValuesFromExpression<HomeController>(c => c.Index());
  15:        return RedirectToRoute(values);
  16:     }
  17:  }

2. The RedirectToAction bug I blogged about has been fixed.

3. They've introduced a helper extension method (MvcControlDataBinder.SourceToDictionary) to convert data sources to a dictionary of values. The supported data source types include

  1. DataSet
  2. DataTable
  3. IDataReader
  4. IList
  5. Array
  6. IQueryable
  7. IEnumerable

Below is an example on how to use this method. While I would never use this to convert a List of models normally, I could see where if you simply need to get truncated key/value list of data with various other sources like IDataReader or IQueryable, this would be beneficial.

   1:  public ActionResult Products()
   2:  {
   3:      List<Product> products = new List<Product>()
   4:      {
   5:          new Product(1, "16 Speed", 499.99m),
   6:          new Product(2, "24 Speed", 699.99m)
   7:      };
   8:   
   9:      Dictionary<object, object> data = 
  10:          MvcControlDataBinder.SourceToDictionary(products, "Id", "Name");
  11:      ViewData["Data"] = data;
  12:   
  13:      return View();
  14:  }

4. The new Ajax support. I'm not going to detail this as Scott Hanselman's post covered a good example and ScottGu will eventually give Part 2 which will be very detailed.

5. As ScottGu already indicated, the Mvc Framework comes with a bunch of new Action Filters, including

  1. AuthorizeAttribute - which uses the membership framework for user authentication and user & role based security.
  2. HandleErrorAttribute - which will enable you to handle exceptions that occur by rendering a specific view when an error occurs. This is equitable to the catch-all error page.
  3. OutputCacheAttribute - Yes, this is what it says it is. Think ASP.NET output caching, and thats what this is.

6. TempData is now "testing friendly"! Well, right out of the box now, that is. They've introduced a new interface ITempDataProvider (and subsequent SessionStateTempDataProvider) that will only be used only when Execute is called from the Controller. The reason TempData is now tester friendly, is that by default it uses TempDataDictionary as a backing field, and Execute will Load/Save from the TempDataProvider set to/from TempData.

kick it on DotNetKicks.com


Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

July 21. 2008 02:53

Pingback from weblogs.asp.net

ASP.NET MVC Preview 4 Finds - eWorld.UI - Matt Hawley

weblogs.asp.net

July 21. 2008 17:35

Is the Html.SubmitButton helper deprecated?

VB

July 22. 2008 00:53

Pingback from zuhaib.in

Zuhaib | ASP.NET MVC Preview 4 Released

zuhaib.in

July 23. 2008 14:35

@VB,

Take a look in Microsoft.Web.Mvc.dll (which is the Futures project). I believe Html.SubmitButton is there now.

Brad Wilson

July 23. 2008 15:05

Thanks Brad - I found in there.... I just wish all these details were included in the release notes

VB

April 25. 2009 04:59

Thanks friends- I found in there.... I just wish all these details were included in the release notes

saç ektirme

April 27. 2009 22:09

very helpful info

Call Center Software

June 1. 2009 22:54

very nices article
http://www.nakliyatfirmalari.org ankara nakliye
http://www.ankara-nakliye.com ankara evden eve nakliyat
http://www.asansorluevdenevenakliyat.com asansörlü evden eve nakliyat
http://www.evdenevenakliyecilik.com evden eve nakliyat

nakliye ankara

June 4. 2009 02:32

Great thanks

yazılım

June 26. 2009 14:51

thanks great post

earn college degree

June 26. 2009 15:48

I just wish all these details were included in the release notes

saç ektirme

affordable degrees

June 26. 2009 15:48

thanks for the information

earn a college degree online

June 26. 2009 15:49

Preview 4 Finds - eWorld.UI - Matt Hawley

online counseling degrees

July 3. 2009 20:45

nakliyat evden eve nakliyat nakliye taşımacılık

sarac

July 5. 2009 21:14

Thanks for sharing these finds.

Affordable crm solutions

July 6. 2009 16:48

thanks for this nice post

Indianapolis web design

July 10. 2009 00:55

Great post. very helpful and informative.

Indianapolis Web Design

July 10. 2009 00:56

Thanks for a nice post. Good notes to have.

Dental Marketing

July 12. 2009 23:38

These are new codings for what? Have anyone got these to work?

Ways to Make Money

July 18. 2009 10:27

I have been associated with SEO work for a long time now.but never knew about this.thanks for sharing it.

SEO

July 20. 2009 21:47

Thank you for useful information was a good article

sex movies

July 22. 2009 09:13

thanksss.. super site..

evden eve nakliyat

July 22. 2009 13:58

thanks you

Porno izle

July 23. 2009 10:23


Thanks for that! Just what I was looking for

Web design

July 24. 2009 04:52

Great discussion.I like the way you have described the article…Keep it up!!!

London Escorts

July 24. 2009 07:54

Nice & Great Site.

Civil Engineering Diploma

July 26. 2009 06:39

Great post i learned a lot from it and will definitely be back at a later date to check out your other posts.

Kamagra

July 26. 2009 07:05

Hi,

can any one tell me any good books as preparation of Microsoft exam of Asp.Net ? ?

online poker

July 29. 2009 22:39

I never knew that. These are some really intriguing details. Thanks ever so much.

Dream beds

July 30. 2009 01:24

Hey I just got through with the pages, I should say Pretty nice work done there.

Best antivirus

August 1. 2009 14:01

interesting. something new learned today. lol
thanks for the helpful stuff.

WebDesignBoy

August 4. 2009 00:57

hi all.
thank too the apple. http://www.germanporn.tk

Porno filme

August 4. 2009 00:59

Thanks a lot for this scripot.I have been looking for it for a long time http://www.tvsexizle.com

Porno izle

August 6. 2009 19:57

Hi,

Can i install more than one anti-virus and run only one at a time while disabling others?

Best antivirus

August 7. 2009 06:40

Thank you very much for this article, has served as much to me and my colleagues look forward to your website to gather more news

no Deposit Casino bonus

August 7. 2009 19:31

Hi,

How I can host a website for free with HTML,ASP.NET and SQL as my contents?

Virus removal

August 11. 2009 00:58

Thanks friends- I found in there.... I just wish all these details were included in the release notes

tiffany

August 12. 2009 18:46

Can somebody offer me free hosting provider?

buy viagra

August 13. 2009 04:26

Nice and great. Thank you.

canon sd1200

August 15. 2009 17:23

Thanks for the info

christmas movies

August 16. 2009 15:04

Can u compare jsp and asp.net over security issues, fastness, cost effective? Which is best to avoid hacking?

web marketing

August 23. 2009 14:03


Hey I just got through with the pages, I should say Pretty nice work done there.

Internet marketing

August 23. 2009 23:03

Erectilde dysfunction treatment or (ED) is not always very difficult. So you should simply buy such generic ed pills like sildenafil, levitra or cialis

Buy Viagra

August 26. 2009 01:03

have found some very interesting

Printer Service Manual

August 28. 2009 18:06

Nice article and great commet. Thanks for sharing

free mobile phone deals offer

August 28. 2009 18:10

Thanks for the information, it was very helpful and useful

contact lens

August 29. 2009 09:00

Why in my pc any anti virus sites are not getting opened?

sex movie

September 4. 2009 12:15

Great article! Thank you very much!

regards

online personal classifieds http://informationex.com

online personal classifieds

September 4. 2009 21:42

Great post! The codes look great. Thanks for this wonderful article. It is really a big help. Keep it up!

Breast reduction Philadelphia

September 5. 2009 11:01

Great blog thanks for your news Smile

online casinos

September 9. 2009 12:30

cool, thanks

lpn salary

September 9. 2009 12:33

cool, thanks

rn jobs

September 9. 2009 12:34

Great blog thanks for your news

online tv

September 11. 2009 21:16

this is a little confusing but I think I can get it to work

live webcam

September 23. 2009 12:31

Really interesting articles.I enjoyed reading it. I need to read more on this topic..Thanks for sharing a nice info...

Free online games

September 25. 2009 10:46

great announcment

Canon t1i

September 25. 2009 23:54

Can u compare jsp and asp.net over security issues, fastness, cost effective? Which is best to avoid hacking?

laptop sale

September 27. 2009 06:41

I really appreciate the effort you have given to this post. I am looking forward for your next post. I found this informative and interesting blog. I just hope you could make another post related to this. This is definitely worth reading.

travel nursing

September 27. 2009 18:51

I am a newbie in website programming, so right now i am trying to gather as much resource i can have to add on my file. This kind of codes are very useful for me while learning how to be web programmer. Thanks

iphone unlock

September 29. 2009 09:47

Hey man, Thxs for huge coding work, Really helpful for my programmign career,.

fap revolution robot

October 1. 2009 07:44

ASP.NET 4 adds an extensibility point to output caching that enables you to configure one or more custom output-cache providers. Output-cache providers can use any storage mechanism to persist HTML content.

Bulk sms

October 2. 2009 00:23

September 25. 2009 23:51

I am a newbie in website programming, so right now i am trying to gather as much resource i can have to add on my file. This kind of codes are very useful for me while learning how to be web programmer. Thanks

multi line slots

October 2. 2009 19:12

This was a really quality post. I'd like to write like this too - taking time and real effort to make a good article.

Viagra prezzo

October 2. 2009 19:13

Really i am impressed from this post. The person who create this post it was a great human. Thanks for shared this with us.

ed trial pack

October 4. 2009 15:46

I am newbie in website designing and programming, so this kinds of post or articles is very helpful to me. I already read a lot and it does give me ideas how it work

unlock iphone

October 5. 2009 03:11

Thank you for the helpful entry, i really liked reading it, keep posting like this.

Dave

Slingshot octane

October 5. 2009 08:23

includes a large selection of free casino games and a global land casino games

Flash online casino

October 6. 2009 18:23

I digged this for more news from you.



Regards and respect
Kinka

bienes raices san miguel de allende

October 6. 2009 18:35

I loved the way you exlained things. Much better many here


Regards

Flashy

toronto furnished apartment

October 7. 2009 04:53

Thanks friends- I found in there.... I just wish all these details were included in the release notes

auto insurance

October 7. 2009 14:48

I posted your blog to my facebook group


Regards

hanitz

buy cheap aion items

October 7. 2009 14:48

I loved the way you exlained things. Much better many here


Regards

krich off

aion items

October 8. 2009 04:46

this will definitely help me in the future. This is so good to see. i have looking for this
for a while.

Adapter

October 8. 2009 11:34

Modify WebFormThemeViewEngine - Write a bunch of code that finds the ... return new ViewEngineResult(this.CreatePartialView(controllerContext, partialPath)); ... How To Setup Custom Theme Support In ASP.NET MVC Preview 4 using a Custom ...

Mobile Phones

October 8. 2009 11:45

First of all let's crate a new MVC application using installed template like below. If you don't know where to get this MVC Preview 4 please check my blog. ... Because here we have functionality implemented with asp .net membership ... Once this is done go to your server explorer and find out the ...

IBM 1932

October 8. 2009 18:28

Indeed a good post, very very helpful for me at least, i have been looking for something similar, i am glad that I got it here, thank you a lot.


Nicole

Silk knot cufflinks

October 8. 2009 23:35

Generic Viagra Online Pharmacy. Buy Viagra Online and Order Cheap Viagra Prescription with Satisfaction Guarantee.

Buy Viagra

October 9. 2009 07:34

Hi nice site design


Regards

barry

buy cheap aion online gold

October 9. 2009 07:34

When is the next post comming on this topic.


Regards

james

aion accounts

October 9. 2009 08:07

How can add progress bar and use it in asp.net please send source code?

singles dating

October 10. 2009 06:18

Hi nice POst

Regards

Honey

home mortgage colorado

October 10. 2009 06:30

this will definitely help me in the future. This is so good to see. i have looking for this

premier league live score

October 10. 2009 06:31

Generic Viagra Online Pharmacy.

Buy cheap kamagra

October 10. 2009 06:32

First of all let's crate a new MVC application using installed template like below.

Kamagra Wholesale suppliers

October 10. 2009 06:32

I loved the way you exlained things. Much better many here

buy viagra

October 10. 2009 07:28

Hi nice site design

scores lives

October 10. 2009 07:29

Indeed a good post,

soccer live score

October 10. 2009 07:29

Hi nice POst

Handball live scores

October 10. 2009 10:00

Credit brokers are frequently ignored when looking for a mortgage. A lot of people do not appreciate the savings that can be made by using a consultant. when looking for a cheap finance quote. Not only can they assist you save you cash, they can in addition offer you important information, and help you realize the complexities that loans involve.
[url=http://www.jp-financial.co.uk]mortgage advisor[/url]

Mortgage Advisor

October 11. 2009 11:00

Hi does this MVC is same as model-view-control?

Deferred Annuity

October 11. 2009 21:43

This article was very helpful for me thanks.

business

October 12. 2009 18:01

great tutorial here!

poor credit loan

October 13. 2009 00:46

I love the instructions you placed here and they seem of great use.

web design

October 13. 2009 08:49

Thanks for sharing information with me.

Cost v Quality

October 13. 2009 16:22

Nice Posting

search engine marketing

October 13. 2009 18:43

I have downloaded a game on my psp and it works. but the music wont play on the game. how can i get the music on the game to play. the sound effects work but not the music. what might be my problem?

harness racing

October 13. 2009 20:43

Please give more details about ASP.NET MVC Preview 4 New Finds.

SEO ranking

October 14. 2009 16:15

Just wanted to say thanks for this.

Cool

October 14. 2009 16:29

Very nice, I was a big fan of your Lambda based RedirectToAction solution so I'm sure this will not be disappointing either.

Vista Drivers

October 14. 2009 16:52

How much do dentists get paid in india?

white teeth

October 15. 2009 11:39

thank you for this useful info.. great post!

www.heavensbest.com/.../rug-cleaning.html
http://www.seattlecarpetcleaning.com

peter north

October 15. 2009 17:46

Would somebody clean these spammy comments?

Naresh Yadav

October 15. 2009 19:01

This is very helpfull for web oranted programmers.Nice post

<a href="http://www.onlinemovieguru.com">watch free movies</a>

cyber

October 16. 2009 21:37

great site

vigrx plus

October 16. 2009 22:07

Hey I just got through with the pages, I should say Pretty nice work done there

free online games

October 19. 2009 10:25

Thank You..
<a href="http://www.medyum.gen.tr">medyum</a>

medyum

October 19. 2009 11:16

Hi,

what does the term 'Technical Defect Analysis' mean in the aviation context?

canon ink cartridges

October 19. 2009 11:25

Thank You..

motorlu panjur

October 21. 2009 02:36

GOOD JOB,I like it!

ed hardy

October 21. 2009 03:33

Good one indeed, thank you for sharing this, i really appreciate it.

Nicole

Medela Symphony

October 21. 2009 15:10

It's truly an interesting and informative post, thank you for posting it.

underground electric dog fence

October 21. 2009 15:18

Thanks for the help


http://www.thefilmwall.com/index/

Mitsha

October 21. 2009 20:54

That code is so awesome...thanks for sharing with us!

Legitimate Work At Home Jobs Opportunity

Comments are closed

Copyright © 2000 - 2010 , Excentrics World