Venkatasai's Blog

<VK:blog runat="server"/>

  • Some useful links for ASP.Net MVC

     

    Here are some links that contains more useful information on ASP.Net MVC.

    ASP.NET MVC Preview 3 Release

    This links contains highlevel chnages in MVC preview 3 release and also link to source code at codeplex.

    Inversion of Control, ASP.NET MVC and Unit Testing

    Fredrik Kalseth has a cool article that talks about the concepts behind inversion of control (IOC) and how you can use this with ASP.NET MVC to better isolate dependencies and enable better unit testing of your code.

    ASP.net MVC, MVCContrib, and Using Spring.net as a Controller ...

    The ASP.net MVC CTP as been out for a few days and I have read quite a number of good posts about using the framework and extending the available.

    Testing Action Results with ASP.NET MVC

    Jeremy Skinner blogs about some cool extension method helpers he has added to MvcContrib to enable pretty sweet testing of Controller actions.

    MVC Membership Starter Kit - 1.2 Release

     Troy Goode has posted an update to his excellent MVC Membership Starter Kit.  This version works with the interim ASP.NET MVC source release.

    MVC Contrib - MvcContrib.org - Home

    This is the contrib project for the ASP.Net MVC framework.

    ASP.NET MVC Framework (Part 4): Handling Form Edit and Post Scenarios

    The last few weeks I have been working on a series of blog posts that cover the new ASP.NET MVC Framework we are working on.  The ASP.NET MVC Framework is an optional approach you can use to structure your ASP.NET web applications to have a clear...

    ASP.NET MVC Framework (Part 3): Passing ViewData from Controllers to Views

    The last few weeks I have been working on a series of blog posts that cover the new ASP.NET MVC Framework we are working on.  The ASP.NET MVC Framework is an optional approach you can use to structure your ASP.NET web applications to have a clear...

    ASP.NET MVC Framework (Part 2): URL Routing

    Last month I blogged the first in a series of posts I'm going to write that cover the new ASP.NET MVC Framework we are working on.  The first post in this series built a simple e-commerce product listing/browsing scenario.  It covered the high...

    ASP.NET MVC Framework (Part 1)

    Two weeks ago I blogged about a new MVC (Model View Controller) framework for ASP.NET that we are going to be supporting as an optional feature soon. It provides a structured model that enforces a clear separation of concerns within applications, and...

    ASP.NET MVC Framework

    One of the things that many people have asked for over the years with ASP.NET is built-in support for developing web applications using a model-view-controller (MVC) based architecture. Last weekend at the Alt.NET conference in Austin I gave the first...

    Stephen Walther has posted very useful articles.

    ASP.NET MVC Tip #1 - Create New HTML Helpers with Extension Methods

    In this tip, I show you how you can create two new HTML Helpers that you can use within an ASP.NET MVC View. I show you how you can use extension methods to create new HTML Helpers for displaying bulleted and numbered lists....

    ASP.NET MVC Tip #2 - Create a custom Action Result that returns Microsoft Excel Documents

    In this tip, I show you how to create a custom action result that you can return from an ASP.NET MVC controller action. This action result generates a Microsoft Excel Document from a LINQ to SQL query....

    ASP.NET MVC Tip #3 - Provide Explicit View Names when Unit Testing

    In this tip, Stephen Walther explains how you can unit test whether a controller action returns a particular view. He recommends that you be explicit about view names when you plan to create unit tests....

    ASP.NET MVC Tip #4 - Create a Custom Data Controller Base Class

    In this tip, you learn how to create a custom controller base class that exposes actions for performing common database operations such as displaying, inserting, updating, and deleting data. ...

    ASP.NET MVC Tip #5 - Create Shared Views

    In this tip, I explain how to create shared views for controller actions. A shared view can be used with multiple controllers. In particular, I explain how to create shared views for displaying and editing database data. ...

    ASP.NET MVC Tip #6 - Call RedirectToAction after Submitting a Form

    In this tip, I explain why you should call the RedirectToAction() method after submitting form data instead of returning a view....

    ASP.NET MVC Tip #7 - Prevent JavaScript Injection Attacks with Html.Encode

    In this tip, Stephen Walther convinces you that JavaScript Injection attacks are much more serious than you might think. I show you how to do very evil things with an ASP.NET MVC website using a JavaScript Injection attack and then I explain an easy way to prevent this type of attack.

    ASP.NET MVC Tip #8 - Create an ASP.NET MVC GridView Helper Method

    In this tip, Stephen Walther shows you how to extend the ASP.NET MVC framework with a new helper method that displays an HTML table of database data. ...

    ASP.NET MVC Tip #9 - Create a GridView View User Control

    In this tip, Stephen Walther demonstrates how to build an ASP.NET MVC View User Control that accepts a set of database records and renders the records in an HTML table automatically. The advantage of using a View User Control is that you can customize the rendering of particular columns. ...

    ASP.NET MVC Tip #10 - Prevent URL Manipulation Attacks

    In this tip, Stephen Walther explains how hackers can steal sensitive information from an ASP.NET MVC website by manipulating URLs. I also discuss how you can build unit tests to prevent this type of attack by mocking the ControllerContext....

    ASP.NET MVC Tip #11 - Use Standard Controller Action Names

    In this tip, I recommend that you use standard names for your controller actions in order to make your code more transparent to other developers. Adopting naming conventions makes your code easier to read for other developers and your future self. Naming...

    Read more...

  • Custom CAPTCHA Image Action Result for ASP.NET MVC

     

    In this post you will see how to create CAPTCHA style image using ActionResult object introduced in April ASP.Net source refresh at code plex

    Create CAPTCHAImageActionResult to render generated image with random text
    Here is the code of custom action result class which do all the work to generate image .Nice thing about this is  back ground color, font color and random text are properties and can be set by controller  based color scheme of your web site.

     

    Create Controller action to process request for CAPTCHA image.
    Create ASP.Net MVC controller class to generate random text and then to return custom CAPTCHAImageActionResult object. Here is the code how it looks like. In this example I am generating simple random text with some numbers and alphabets

    Use in view pages

    Now it is time to use this in other view pages, add below line in any of view page. In this example I have used in homepage.


    <img alt="CAPTCHA Image" src="<%=Url.Action("Index","CAPTCHAImage") %>"/>

    Here is how the screen looks like.  

     You can download sample code here

    Read more...

  • Latest interim release of ASP.NET MVC source code

    ASP.Net team has published a refresh of source code on code plex with following new features.

  • Action methods on Controllers now by default return an ActionResult instance, instead of void.
    • This ActionResult object indicates the result from an action (a view to render, a URL to redirect to, another action/route to execute, etc).
    • Each "result" is a type that inherits from ActionResult. To render a view, return a RenderViewResult instance.
  • The RenderView(), RedirectToAction(), and Redirect() helper methods on the Controller base class now return typed ActionResult objects (which you can further manipulate or return back from action methods).
  • The RenderView() helper method can now be called without having to explicitly pass in the name of the view template you want to render.
    • When you omit the template name the RenderView() method will by default use the name of the action method to determine the view template to render.
    • So calling RenderView() with no parameters inside the About() action method is now the same as explicitly writing RenderView('About').
  • Introduced a new IActionFilter interface for action filters. ActionFilterAttribute implements IActionFilter.
  • Action Filters now have four methods they can implement representing four possible interception points.
    • OnActionExecuting which occurs just before the action method is called.
    • OnActionExecuted which occurs after the action method is called, but before the result is executed (aka before the view is rendered in common scenarios).
    • OnResultExecuting which occurs just before the result is executed (aka before the view is rendered in common scenarios).
    • OnResultExecuted which occurs after the result is executed (aka after the view is rendered in common scenarios).
    • NOTE: The OnResult* methods will not be called if an exception is not handled during the invoking of the OnAction* methods or the action method itself.
  • Added a MapRoute extension method (extension on RouteCollection) for use in declaring MVC routes in a simpler fashion.
  • Look at following link for more iformation http://weblogs.asp.net/scottgu/archive/2008/04/16/asp-net-mvc-source-refresh-preview.aspx.

    Read more...