eWorld.UI - Matt Hawley

Ramblings of Matt

Lambda Based RedirectToAction Sample Updated to MVC Preview 3

May 29, 2008 18:44 by matthaw

I took my Lambda based RedirectToAction solution I previously blogged about and updated it to work against the Preview 3 bits. I also took the liberty to fix the bug where you couldn't actually call another controller's action. Some notable changes in the source, is that ActionRedirectResult is no more - as it's replaced with RedirectToRouteResult. I think this was a good consolidation between RedirectToAction and RedirectToRoute since they basically do exactly the same thing. You'll also notice that there are 3 more extension methods, which was necessary to fix the prior bug. Now, you can write code like

   1:  // for actions off of the current controller
   2:  return this.RedirectToAction(c => c.Login());
   3:  return this.RedirectToAction(c => c.Login("matt"));
   4:   
   5:  // alternatively, within the UserController you can do the following
   6:  return this.RedirectToAction<ProductController>(c => c.View(102));

I'm not going to post the entire code sample as you can download it here. Enjoy it, and let me know of anything else you'd like to see.

kick it on DotNetKicks.com


Be the first to rate this post

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

Comments

June 2. 2008 18:42

Pingback from weblogs.asp.net

Lambda Based RedirectToAction Sample Updated to MVC Preview 3 - eWorld.UI - Matt Hawley

weblogs.asp.net

June 3. 2008 06:57

Hi Matt,

Would you be interested in including this in mvccontrib?

Jeremy

Jeremy Skinner

June 3. 2008 07:13

@Jeremy - yeah, I'll get it in there probably late next week

matthaw

June 3. 2008 12:31

Not only did this fix my problem calling another controller's action, but it fixed my problem where my session variable was being destroyed. Much obliged!

Mike B

June 9. 2008 17:27

Perfect! Thanks.

Seth Websterer.com

June 20. 2008 13:02

Nice job, this is great. I removed the (this) extension bits and just added it to my base controller class overloading RedirectToAction since it doesn't have any conflicting <T> methods and the signatures are unique. Works like a charm, and is much cleaner. I hope they add this into the core MVC eventually.

Shannon

June 30. 2008 02:06

Building off of this example, I suppose we can also do this...

<%= Html.ActionLink<ProductController>(c => c.View(102)) %>

David J Hu

August 25. 2008 21:08

I almost started to build it myself, good job. Hopefully it will be added to the MVC core.

jorg visch

June 2. 2009 06:21

<%= Html.ActionLink<ProductController>(c => c.View(102)) %>

that's right thanks david.

Lap Band

June 3. 2009 23:36

Cool

yazılım

June 13. 2009 11:46

Thanks for update ya.

furnace filter

June 14. 2009 03:07

I almost started to build it myself, good job. Hopefully it will be added to the MVC core.

dog forums

June 25. 2009 14:51

Works like a charm, and is much cleaner. I hope they add this into the core MVC eventually.

affordable online education

June 25. 2009 14:54

good job. Hopefully it will be added to the MVC core.

online colleges degree

July 6. 2009 15:11

thanks for the preview looks nice

Define

July 6. 2009 15:13

thanks a lotf or sharing this with us

Weight loss pills

July 20. 2009 22:49

Thank you for useful information was a good article

sex movies

July 24. 2009 09:38

Trying to learn more about MVC and its applications.

Danny

July 24. 2009 09:48

Nice contrib. Thx.

London Tours

July 27. 2009 20:32

This resource deserves a second look. This tip is very important to those who use Lambda. Maybe I would try to use this also since Matthew is here to help us. Thanks dude.

Philadelphia Plastic Surgery

July 27. 2009 21:18

Finally someone who understands RedirectToRouteResult and is able to explain it. Thank you for helping us with this Matthaw.

Receptionist

August 4. 2009 07:59

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

Porno filme

August 4. 2009 08:00

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

Porno izle

August 11. 2009 07:14

On the other hand the article is primarily about avoiding strings. The application on MonoRail is just an example (btw, maybe you missed that it's about MonoRail, not ASP.NET MVC)

online casinos

August 11. 2009 10:03

Not only did this fix my problem calling another controller's action, but it fixed my problem where my session variable was being destroyed. Much obliged!

tiffany

August 13. 2009 03:52

I donn\'t think so tiffany...

cialis online

August 21. 2009 05:46

Very good script. Lots of valuable info. Thanks,

Employment

August 23. 2009 22:26

Very good and interesting site Smile

no Deposit Casino bonus

August 29. 2009 01:39

Thanks for information its a interesting articles.Nice blog site work.

Acne Skin care

September 3. 2009 11:06

I removed the (this) extension bits and just added it to my base controller class overloading RedirectToAction since it doesn't have any conflicting
it fixed my problem where my session variable was being destroyed

Free games

September 3. 2009 19:26

this is really good site.having valuble information

Shopping

September 8. 2009 21:56

Very good script. Lots of valuable info. Thanks

forex trading system

September 8. 2009 21:57

I removed the (this) extension bits and just added it to my base controller class overloading RedirectToAction since it doesn't have any conflicting
it fixed my problem where my session variable was being destroyed

free forex day trading system

September 10. 2009 01:20

This site is really good to watch.Thanks for sharing the posts.
Regards,

poker bonuses

September 10. 2009 01:22

Intresting artcles are present in this site.Thanks for shareing.
Regards,

poker bonuses

September 10. 2009 04:16

I almost started to build it myself, good job. Hopefully it will be added to the MVC core.

auto insurance quotes

September 10. 2009 09:24

This is a very good note. it fixed my problem where my session variable was being destroyed.
Regards,

Narrative Essay

September 11. 2009 02:33

This tip is very important to those who use Lambda. Maybe I would try to use this also since Matthew is here to help us. Thanks you.

Elizabeth Bay Real Estate

September 11. 2009 02:41

As a new user I come to know about the MVC and its application. Really like it.

Compare Car Insurance

September 17. 2009 22:41

Nice job.Works like a charm, and much cleaner. I hope they add this into the core MVC eventually.Good sharing.

Personal Injury Lawyer

September 17. 2009 23:01



very good artcles are present in this site.Thanks for shareing.
Regards,

Credit Card Applications

September 18. 2009 17:10

The application on MonoRail is just an example (btw, maybe you missed that it's about MonoRail, not ASP.NET MVC).
Regards,

free extra chips

September 18. 2009 20:29

Trying to learn more about MVC and its applications.Intresting artcles are present in this site.Thanks for sharing..

Free online games

September 19. 2009 09:32

We need to learn more from this. These a are just simple codes but it can really make business processes more efficient. Thanks for sharing this very useful information.

Buy Dissertation

September 19. 2009 09:33

Is it good to bath with hot water for Health Reason ?

weight loss supplement reviews

September 19. 2009 09:35

What to do with microprocessor and operating system?

bodybuilding suppliments

September 19. 2009 11:25

As a new user I come to know about the MVC and its application. Really like it.

<a href="www.travelinsurance-quotes.com.au/"> Travel Insurance Australia </a>

Travel Insurance Australia

September 20. 2009 02:47

Utilizing Lambda expressions, make the RedirectToAction method much easier to use, read, a

Ceiling Insulation

September 21. 2009 19:13

I hope they add this into the core MVC eventually.

FCredit Card Comparison

September 22. 2009 04:52

I think this is a good point. thanks for the great article, this really nice blog.

Buy Essay

September 24. 2009 11:17


Where can I find a simple java web applciation tutorial that uses MVC?

Life insurance

September 24. 2009 17:26

Nice job, this is great. I removed the extension bits and just added it to my base controller class overloading RedirectToAction since it doesn't have any conflicting methods and the signatures are unique. Works like a charm, and is much cleaner. I hope they add this into the core MVC eventually.

Trade Show Literature rack

September 25. 2009 02:33

Can anyone suggest me one good book to learn spring mvc in J2EE?

laptop

September 25. 2009 02:49

Hi,

Nice article....Very good script also , Can anyone tell me where can i find successful business model for Portal Business ?

online poker

September 26. 2009 05:30

As a new user I come to know about the MVC and its application. Really like it.


<a href=" http://www.DigBands.com/blues/"> Blues </a>

Blues

September 27. 2009 10:32

Thanks a lot, guys!

посуточная аренда квартир в киеве

September 27. 2009 15:34

I found this post very usefull because I have been encoutering some bugs also and this helped a lot. Thanks for sharing the discoveries, I will keep reading your posts to learn more.

Free Internet Advertising

September 27. 2009 21:36

This post is very useful to us.Utilizing Lambda expressions, make the Redirect To Action method much easier to use, read, and refactor! This update took the original sample and it now works with the MVC Preview 3 bits.

Sarong

Sarong

September 29. 2009 01:44

Nice post to hang on..I really loved it the way of the stuff provided in this article..This has given very useful information.

wine club

October 1. 2009 21:28

These are very informative writings. I would try to use this also since Matthew is here to help us. Thanks you.

Business Essay

October 2. 2009 04:36

I found so many interesting in your blog especially on how to determine the topic. keep up the good work.

Essay

October 3. 2009 00:01

Thank you for this very useful information. This was a good article.

casinos online

October 3. 2009 21:39

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post

free diet plans

October 4. 2009 15:22

It is very interesting site.Lambda Based RedirectToAction Sample Updated to MVC Preview 3 world site.

<a href=" http://www.allsarongs.com/"> Sarong </a>

Sarong

October 4. 2009 16:31

Hi, thanks for sharing a nice information. Awaiting for more such informative post.

Lawyers Forrest

October 4. 2009 19:32

Thank you for this very useful information. This was a good article.

Aircraft Fastener Components

October 5. 2009 13:18

Very interesting site..Useful information shared..Iam very happy to read this article..thanks for giving us nice info..Keep up the work..

best teeth whitening products

October 5. 2009 13:53

I enjoyed reading it. I need to read more on this topic..Thanks for sharing a nice info...Iam very much impressed with the info given by this site..

acai berries

October 5. 2009 13:56

I am very glad to see such information which I was searching for a long time.This made very glad..This site has given us an useful information..

anti aging products

October 5. 2009 17:47

I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.

Bidz Reviews

October 5. 2009 18:51

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

colon cleanse products

October 6. 2009 15:01

I removed the extension bits and just added it to my base controller class overloading RedirectToAction since it doesn't have any conflicting methods and the signatures are unique. Works like a charm, and is much cleaner. I hope they add this into the core MVC eventually.

Svensk Handel

October 6. 2009 16:59

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

free music download websites

October 6. 2009 22:17

Great blog to find best online casino

online casino

October 7. 2009 00:08

You have provided answers for almost all the questions I had in my head.I need to read more on this topic..Thanks for sharing a nice info...

work at home jobs

October 7. 2009 09:06

The topic which you chosen for discussion is really very good....Thanks.

Affordable Car Insurance

October 8. 2009 08:30

The Redirect To Action method much easier to use, read, and refactor! This update took the original sample and it now works with the MVC Preview 3 bits.Thanks for shareing the posts.
Regards,

Acne treatment

October 8. 2009 10:42

very glad to see such information which I was searching for a long time.This made very glad..This site has given us an useful information..

Gay DVD

October 8. 2009 16:40

4RX is an online pharmacy to Buy Viagra online. Buy cheap generic drugs like Sildenafil (GENERIC VIAGRA) online and Generic Levitra Online.

Buy Viagra

October 9. 2009 00:26


The internet is with a doubt growing into the most important medium of communication across the globe and its due to sites like this that ideas are spreading so quickly.

Cheap Travel Insurance

October 9. 2009 04:15

We need to learn more from this. These a are just simple codes but it can really make business processes more efficient. Thanks for sharing this very useful informatiom

acai

October 9. 2009 09:02

this is what i have been looking for. I have been looking for a fix for this. I will have to try it.

Auto

October 9. 2009 09:03

We definitely need to learn from this. this will definitely help me in the future.

Auto

October 9. 2009 21:05

What are basic requirement while driving a car?

Driving school melbourne

October 9. 2009 21:06

What are the benifits of driving a car?

Internet marketing

October 9. 2009 22:50

We definitely need to learn from this. this will definitely help me in the future.

cheapest kamagra

October 9. 2009 22:50

this is what i have been looking for. I have been looking for a fix for this. I will have to try it.

kamagra generic viagra

October 9. 2009 22:50

We need to learn more from this

kamagra 100mg

October 9. 2009 22:51

The topic which you chosen for discussion is really very good....Thanks.

live scoring

October 9. 2009 22:51

Great blog to find best online casino

latest scores

October 12. 2009 20:04


The content on this site is unique. A good work done related to tutorials and must be carried on.

Travel Insurance Online

October 13. 2009 04:32

I am very happy to see your blog article such a nice information witch i was searching for a very long time enjoyed reading it is a really interesting articles they provided answers for almost all the questions I had in my head..it's a nice blog

Dispute credit report items

October 14. 2009 01:55

Useful information shared..Iam very happy to read this article..thanks for giving us nice info.Fantastic walk-through. I appreciate this post.

green tea benefits

October 16. 2009 00:07

Utilizing Lambda expressions, make the Redirect To Action method much easier to use, read, and refactor! This update took the original sample and it now works with the MVC Preview 3 bits.It is very interesting site.

<a href="www.AllSarongs.com">Sarong</a>

sarong

October 17. 2009 02:18

I am very glad to see such information which I was searching for a long time.This made very glad..This site has given us an useful information

free online games

October 17. 2009 02:46



We definitely need to learn from this. this will definitely help me in the future.

mirror

October 17. 2009 03:51

Thanks for the update on this.

Air Filters

October 17. 2009 12:38

This is what i have been looking for. I have been looking for a fix for this. I will have to try it.

http://www.AllSarongs.com

sarong

October 18. 2009 20:28

Air is needed for old porcelain

porcelain

October 19. 2009 13:02

I bookmarked your post will read this latter


Regards

Morris

best hotels bangkok

October 19. 2009 19:35

I think this was a good consolidation between RedirectToAction and RedirectToRoute since they basically do exactly the same thing. I thing some more extensions are needed to fix the bug though

dog fence

October 20. 2009 08:35

Very helpful info, especially for those of us that are technically challenged.

Travel Insurance Online

October 21. 2009 02:36

GOOD JOB,I like it!

ed hardy

October 21. 2009 03:20

Lambda? Well, pretty interesting new application to know. Thank you for sharing those codes, but since this is the first time i heard and read about it, I am going to digg more resources about it.

online gambling

October 21. 2009 03:37

Another cool entry, you are doing great work, keep it up.

Debra

Medela Symphony

October 21. 2009 03:55


Admiring the time and effort you put into your blog and detailed information you offer!

Pet health insurance

October 21. 2009 04:31

Home buyers are going to be pretty rich even when they buy a house considering the value of houses in this economic crisis, house prices are a steal.

Home loan

October 21. 2009 10:30

Very interesting post to hang on..Iam really impressed with this article..Looking for more info..

four seasons wine

October 22. 2009 05:22

Lambda Based RedirectToAction Sample Updated to MVC Preview 3 ? It well , pretty interesting new application to know.Thanks four post.

<a href="www.premiertimeshareresale.com">Timeshare Resales</a>

Timeshare Resales

Comments are closed

Copyright © 2000 - 2010 , Excentrics World